this repo has no description
0
fork

Configure Feed

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

Merge pull request #1667 from joshgoebel/mkdir_failure

(enh) errors when mkdir fails

authored by

Vadim Grigoruk and committed by
GitHub
262a67aa 203dc6c9

+17 -6
+4 -2
src/studio/fs.c
··· 906 906 return fs_read(tic_fs_pathroot(fs, name), size); 907 907 } 908 908 909 - void tic_fs_makedir(tic_fs* fs, const char* name) 909 + bool tic_fs_makedir(tic_fs* fs, const char* name) 910 910 { 911 911 #if defined(BAREMETALPI) 912 912 // TODO BAREMETALPI ··· 925 925 dbg("Could not mkdir %s\n", name); 926 926 } 927 927 free(path); 928 + return (res != FR_OK); 928 929 #else 929 930 930 931 const FsString* pathString = utf8ToString(tic_fs_path(fs, name)); 931 - tic_mkdir(pathString); 932 + int result = tic_mkdir(pathString); 932 933 freeString(pathString); 933 934 934 935 #if defined(__EMSCRIPTEN__) 935 936 syncfs(); 936 937 #endif 938 + return result; 937 939 #endif 938 940 } 939 941
+1 -1
src/studio/fs.h
··· 46 46 bool tic_fs_saveroot (tic_fs* fs, const char* name, const void* data, s32 size, bool overwrite); 47 47 void* tic_fs_load (tic_fs* fs, const char* name, s32* size); 48 48 void* tic_fs_loadroot (tic_fs* fs, const char* name, s32* size); 49 - void tic_fs_makedir (tic_fs* fs, const char* name); 49 + bool tic_fs_makedir (tic_fs* fs, const char* name); 50 50 bool tic_fs_exists (tic_fs* fs, const char* name); 51 51 void tic_fs_openfolder (tic_fs* fs); 52 52 bool tic_fs_isdir (tic_fs* fs, const char* dir);
+12 -3
src/studio/screens/console.c
··· 1255 1255 { 1256 1256 if(console->desc->count) 1257 1257 { 1258 + char msg[TICNAME_MAX]; 1258 1259 const char* param = console->desc->params->key; 1259 1260 1260 - tic_fs_makedir(console->fs, param); 1261 + if (tic_fs_exists(console->fs, param)) { 1262 + sprintf(msg, "\nerror, [%s] already exists :(", param); 1263 + printError(console, msg); 1264 + commandDone(console); 1265 + return; 1266 + } 1261 1267 1262 - char msg[TICNAME_MAX]; 1263 1268 sprintf(msg, "\ncreated [%s] folder :)", param); 1264 - printBack(console, msg); 1269 + 1270 + printBack(console, tic_fs_makedir(console->fs, param) 1271 + ? "\nerror, dir not created :(" 1272 + : msg); 1273 + 1265 1274 } 1266 1275 else printError(console, "\ninvalid dir name"); 1267 1276