fix some path handling issues
This commit is contained in:
@@ -101,9 +101,11 @@ static char *get_parent_folder(const char path[static 1]) {
|
||||
if (!last_separator)
|
||||
return NULL;
|
||||
|
||||
size_t length = last_separator - path;
|
||||
// add one for the trailing slash
|
||||
size_t length = last_separator - path + 1;
|
||||
char *parent = calloc(length, sizeof(char));
|
||||
strncpy(parent, path, length);
|
||||
parent[length - 1] = '/';
|
||||
parent[length] = '\0';
|
||||
return parent;
|
||||
}
|
||||
@@ -148,7 +150,7 @@ HiloadResult file_watch_add(hiFileWatcherContext *ctx, u32 mask,
|
||||
bool exists = false;
|
||||
for (size_t i = 0; i < sc_array_size(&parent_watch->files); i++) {
|
||||
const char *file = sc_array_at(&parent_watch->files, i);
|
||||
// we store the pointer, so this should be fine
|
||||
// we store the pointer directly, so this should be fine :D
|
||||
if (file == watch->path) {
|
||||
exists = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user