Storage check trailing slash on subdir check

This commit is contained in:
Willy-JL
2023-07-14 19:48:41 +02:00
parent 849c801a37
commit b5744fac21

View File

@@ -421,9 +421,14 @@ FS_Error storage_common_remove(Storage* storage, const char* path) {
}
bool storage_is_subdir(const char* a, const char* b) {
char test[strlen(b) + 2];
snprintf(test, sizeof(test), "%s/", b);
return strncmp(a, test, sizeof(test) - 1) == 0;
size_t len = strlen(b) + 2;
char test[len];
strncpy(test, b, len);
if(test[len - 3] != '/') {
test[len - 2] = '/';
test[len - 1] = '\0';
}
return strncmp(a, test, len - 1) == 0;
}
FS_Error storage_common_rename(Storage* storage, const char* old_path, const char* new_path) {