Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sp.h
Original file line number Diff line number Diff line change
Expand Up @@ -15656,7 +15656,7 @@ sp_err_t sp_fs_create_dir(sp_str_t path) {

// Walk up, collecting intermediate paths that don't exist
path = sp_fs_trim_path(path);
while (!sp_fs_is_root(path) && !sp_fs_exists(path)) {
while (!sp_str_empty(path) && !sp_fs_is_root(path) && !sp_fs_exists(path)) {
sp_da_push(missing, path);
path = sp_fs_parent_path(path);
}
Expand Down
16 changes: 16 additions & 0 deletions test/fs/create_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ UTEST_F(fs_create_dir, create_multi_level) {
});
}

UTEST_F(fs_create_dir, create_multi_level_relative) {
SKIP_ON_WASM()
sp_str_t sandbox = sp_test_file_path(&ut.file_manager, sp_str_lit("create_multi_level_relative"));
sp_fs_create_dir(sandbox);

sp_str_t cwd = sp_fs_get_cwd(ut.file_manager.mem);
ASSERT_EQ(sp_sys_chdir_s(sandbox), 0);
sp_err_t result = sp_fs_create_dir(sp_str_lit("rel1/rel2"));
ASSERT_EQ(sp_sys_chdir_s(cwd), 0);

EXPECT_EQ(result, SP_OK);
sp_str_t created = sp_fs_join_path(ut.file_manager.mem, sandbox, sp_str_lit("rel1/rel2"));
EXPECT_TRUE(sp_fs_exists(created));
EXPECT_EQ(sp_fs_get_kind(created), SP_FS_KIND_DIR);
}

UTEST_F(fs_create_dir, destination_is_file) {
SKIP_ON_WASM()
run_create_dir_test(&ur, &ut.file_manager, (create_dir_test_t){
Expand Down
Loading