]> git.lizzy.rs Git - nothing.git/blobdiff - src/system/file.c
Remove TODO(#943)
[nothing.git] / src / system / file.c
index 1822b228201ce9ab18ec77dfa92cc625b987673c..c0be2f57e7eb8957be9bf67e2c6a096436edcc6e 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
+#include "system/nth_alloc.h"
 #ifdef __linux__
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -12,6 +13,7 @@
 
 #include "system/stacktrace.h"
 #include "file.h"
+#include "lt_adapters.h"
 
 int last_modified(const char *filepath, time_t *time)
 {
@@ -91,7 +93,7 @@ DIR *opendir(const char *dirpath)
 
     DIR *dir = nth_calloc(1, sizeof(DIR));
 
-    dir->hFind = FindFirstFile(name, &dir->data);
+    dir->hFind = FindFirstFile(buffer, &dir->data);
     if (dir->hFind == INVALID_HANDLE_VALUE) {
         goto fail;
     }
@@ -108,6 +110,8 @@ fail:
 
 struct dirent *readdir(DIR *dirp)
 {
+    trace_assert(dirp);
+
     if (dirp->dirent == NULL) {
         dirp->dirent = nth_calloc(1, sizeof(struct dirent));
     } else {
@@ -120,7 +124,7 @@ struct dirent *readdir(DIR *dirp)
 
     strncpy(
         dirp->dirent->d_name,
-        dirp->data.cFilename,
+        dirp->data.cFileName,
         sizeof(dirp->dirent->d_name) - 1);
 
     return dirp->dirent;