this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

break out fs_isdir and use it to test fs argument (#2680)

* break out fs_isdir and use it to test fs argument

* restore defined(BAREMETALPI) condition to isdir implementation

authored by

Matt Zykan and committed by
GitHub
0e34eaaa 70ee0b6c

+18 -9
+15 -7
src/studio/fs.c
··· 545 545 free(enumPublicDirsData); 546 546 } 547 547 548 + bool fs_isdir(const char* path) 549 + { 550 + #if defined(BAREMETALPI) 551 + // This function isn't applicable to baremetal. 552 + return false; 553 + #else 554 + struct tic_stat_struct s; 555 + const FsString* pathString = utf8ToString(path); 556 + bool isdir = tic_stat(pathString, &s) == 0 && S_ISDIR(s.st_mode); 557 + freeString(pathString); 558 + return isdir; 559 + #endif 560 + } 561 + 548 562 bool tic_fs_isdir(tic_fs* fs, const char* name) 549 563 { 550 564 if (*name == '.') return false; ··· 559 573 560 574 return s.fattrib & AM_DIR; 561 575 #else 562 - const char* path = tic_fs_path(fs, name); 563 - struct tic_stat_struct s; 564 - const FsString* pathString = utf8ToString(path); 565 - bool ret = tic_stat(pathString, &s) == 0 && S_ISDIR(s.st_mode); 566 - freeString(pathString); 567 - 568 - return ret; 576 + return fs_isdir(tic_fs_path(fs, name)); 569 577 #endif 570 578 } 571 579
+1
src/studio/fs.h
··· 59 59 60 60 u64 fs_date (const char* name); 61 61 bool fs_exists (const char* name); 62 + bool fs_isdir (const char* path); 62 63 void* fs_read (const char* path, s32* size); 63 64 bool fs_write (const char* path, const void* data, s32 size); 64 65 void fs_enum (const char* path, fs_list_callback callback, void* data);
+2 -2
src/studio/studio.c
··· 2756 2756 { 2757 2757 const char *path = args.fs ? args.fs : folder; 2758 2758 2759 - if (fs_exists(path)) 2759 + if (fs_isdir(path)) 2760 2760 { 2761 2761 studio->fs = tic_fs_create(path, 2762 2762 #if defined(BUILD_EDITORS) ··· 2768 2768 } 2769 2769 else 2770 2770 { 2771 - fprintf(stderr, "error: folder `%s` doesn't exist\n", path); 2771 + fprintf(stderr, "error: `%s` is not a folder\n", path); 2772 2772 exit(1); 2773 2773 } 2774 2774 }