Browse Source

Fix directories not setting size field correctly

filter-focus
Macoy Madson 1 month ago
parent
commit
1ac3a0c499
  1. 13
      src/FileSystem.cake

13
src/FileSystem.cake

@ -178,7 +178,8 @@
(fsdebugf "\t\tdirectory"))
((S_ISREG (field details st_mode)) ;; File; populate details
(set (field new-details is-directory) false)
(set (field new-details size) (field details st_size))))
(set (field new-details size) (field details st_size))
(set (field new-entry size) (field details st_size))))
(set (field new-details can-read) (bit-and (field details st_mode) S_IROTH))
@ -298,17 +299,14 @@
;; Filter current dir and parent dir
;; Ignore links? Doesn't appear to be necessary, at least not on my system
(unless (or ;; (bit-and (field find-data dwFileAttributes) FILE_ATTRIBUTE_REPARSE_POINT)
(= 0 (strcmp (field find-data cFileName) ".."))
(= 0 (strcmp (field find-data cFileName) ".")))
(= 0 (strcmp (field find-data cFileName) ".."))
(= 0 (strcmp (field find-data cFileName) ".")))
(var is-directory bool (bit-and (field find-data dwFileAttributes)
FILE_ATTRIBUTE_DIRECTORY))
(var new-entry directory-entry (array 0))
;; TODO String interning?
(set (field new-entry name) (strdup (field find-data cFileName)))
(set (field new-entry is-directory) is-directory)
(dynarray-push (deref directories-dynarray) new-entry)
(var new-entry-details entry-details (array 0))
(scope
(var full-path ([] 1024 char) (array 0))
@ -331,7 +329,8 @@
;; (? is-directory "dir" "file")
;; ;; Wrong!
;; (type-cast (field new-entry-details size) int))
(dynarray-push (deref entry-details-dynarray) new-entry-details))
(dynarray-push (deref entry-details-dynarray) new-entry-details)
(dynarray-push (deref directories-dynarray) new-entry))
(unless (FindNextFile find-handle (addr find-data))
(break)))

Loading…
Cancel
Save