Commit: 5e2feb594a335bc7e8a834e8c559ef829862d213
Parent: ff39ae97d3787079e0a78305cfb2b90fc4e0b72d
Author: Randy Palamar
Date:   Sat, 24 May 2025 08:24:23 -0600
fix file watching for files in the cwd
Diffstat:
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/os_linux.c b/os_linux.c
@@ -83,7 +83,11 @@ function OS_ADD_FILE_WATCH_FN(os_add_file_watch)
 {
 	str8 directory = path;
 	directory.len  = str8_scan_backwards(path, '/');
-	if (directory.len < 0) directory = str8("./");
+	if (directory.len < 0) {
+		directory = str8(".");
+	} else {
+		path = str8_cut_head(path, directory.len + 1);
+	}
 
 	u64 hash = str8_hash(directory);
 	FileWatchContext *fwctx = &os->file_watch_context;
@@ -99,5 +103,5 @@ function OS_ADD_FILE_WATCH_FN(os_add_file_watch)
 	FileWatch *fw = da_push(a, dir);
 	fw->user_data = user_data;
 	fw->callback  = callback;
-	fw->hash      = str8_hash(str8_cut_head(path, dir->name.len + 1));
+	fw->hash      = str8_hash(path);
 }
diff --git a/os_win32.c b/os_win32.c
@@ -200,7 +200,11 @@ function OS_ADD_FILE_WATCH_FN(os_add_file_watch)
 {
 	str8 directory  = path;
 	directory.len = str8_scan_backwards(path, '\\');
-	if (directory.len < 0) directory = str8(".\\");
+	if (directory.len < 0) {
+		directory = str8(".");
+	} else {
+		path = str8_cut_head(path, directory.len + 1);
+	}
 
 	u64 hash = str8_hash(directory);
 	FileWatchContext *fwctx = &os->file_watch_context;
@@ -230,5 +234,5 @@ function OS_ADD_FILE_WATCH_FN(os_add_file_watch)
 	FileWatch *fw = da_push(a, dir);
 	fw->user_data = user_data;
 	fw->callback  = callback;
-	fw->hash      = str8_hash(str8_cut_head(path, dir->name.len + 1));
+	fw->hash      = str8_hash(path);
 }