Safety checks for dummy file / dir creation

This commit is contained in:
d0k3 2018-07-18 00:16:41 +02:00
parent bc5f187a0f
commit 6a04bfca67

View File

@ -367,14 +367,15 @@ bool FileCreateDummy(const char* cpath, const char* filename, u64 size) {
f_sync(&dfile); f_sync(&dfile);
fx_close(&dfile); fx_close(&dfile);
return true; return (fa_stat(npath, NULL) == FR_OK);
} }
bool DirCreate(const char* cpath, const char* dirname) { bool DirCreate(const char* cpath, const char* dirname) {
char npath[256]; // 256 is the maximum length of a full path char npath[256]; // 256 is the maximum length of a full path
if (!CheckWritePermissions(cpath)) return false; if (!CheckWritePermissions(cpath)) return false;
snprintf(npath, 255, "%s/%s", cpath, dirname); snprintf(npath, 255, "%s/%s", cpath, dirname);
return (fa_mkdir(npath) == FR_OK); if (fa_mkdir(npath) != FR_OK) return false;
return (fa_stat(npath, NULL) == FR_OK);
} }
bool DirInfoWorker(char* fpath, bool virtual, u64* tsize, u32* tdirs, u32* tfiles) { bool DirInfoWorker(char* fpath, bool virtual, u64* tsize, u32* tdirs, u32* tfiles) {