|
@@ -15,30 +15,15 @@ find_data_to_file_info :: proc(base_path: string, d: ^win32.WIN32_FIND_DATAW, al
|
|
return
|
|
return
|
|
}
|
|
}
|
|
path := concatenate({base_path, `\`, win32_utf16_to_utf8(d.cFileName[:], temp_allocator()) or_else ""}, allocator) or_return
|
|
path := concatenate({base_path, `\`, win32_utf16_to_utf8(d.cFileName[:], temp_allocator()) or_else ""}, allocator) or_return
|
|
|
|
+
|
|
|
|
+
|
|
fi.fullpath = path
|
|
fi.fullpath = path
|
|
fi.name = basename(path)
|
|
fi.name = basename(path)
|
|
fi.size = i64(d.nFileSizeHigh)<<32 + i64(d.nFileSizeLow)
|
|
fi.size = i64(d.nFileSizeHigh)<<32 + i64(d.nFileSizeLow)
|
|
|
|
|
|
- if d.dwFileAttributes & win32.FILE_ATTRIBUTE_READONLY != 0 {
|
|
|
|
- fi.mode |= 0o444
|
|
|
|
- } else {
|
|
|
|
- fi.mode |= 0o666
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- is_sym := false
|
|
|
|
- if d.dwFileAttributes & win32.FILE_ATTRIBUTE_REPARSE_Point == 0 {
|
|
|
|
- is_sym = false
|
|
|
|
- } else {
|
|
|
|
- is_sym = d.dwReserved0 == win32.IO_REPARSE_TAG_SYMLINK || d.dwReserved0 == win32.IO_REPARSE_TAG_MOUNT_POINT
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if is_sym {
|
|
|
|
- fi.type = .Symlink
|
|
|
|
- } else if d.dwFileAttributes & win32.FILE_ATTRIBUTE_DIRECTORY != 0 {
|
|
|
|
- fi.type = .Directory
|
|
|
|
- fi.mode |= 0o111
|
|
|
|
- }
|
|
|
|
|
|
+ fi.type, fi.mode = _file_type_mode_from_file_attributes(d.dwFileAttributes, nil, d.dwReserved0)
|
|
|
|
|
|
|
|
+ // fi.inode = u128(u64(d.nFileIndexHigh)<<32 + u64(d.nFileIndexLow))
|
|
fi.creation_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftCreationTime))
|
|
fi.creation_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftCreationTime))
|
|
fi.modification_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastWriteTime))
|
|
fi.modification_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastWriteTime))
|
|
fi.access_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastAccessTime))
|
|
fi.access_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastAccessTime))
|
|
@@ -60,31 +45,33 @@ _read_directory_iterator :: proc(it: ^Read_Directory_Iterator) -> (fi: File_Info
|
|
if it.f == nil {
|
|
if it.f == nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if it.impl.no_more_files {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
|
|
-
|
|
|
|
- err: Error
|
|
|
|
- fi, err = find_data_to_file_info(it.impl.path, &it.impl.find_data, file_allocator())
|
|
|
|
- if err != nil {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- if fi.name != "" {
|
|
|
|
|
|
+ for !it.impl.no_more_files {
|
|
|
|
+ err: Error
|
|
file_info_delete(it.impl.prev_fi, file_allocator())
|
|
file_info_delete(it.impl.prev_fi, file_allocator())
|
|
- it.impl.prev_fi = fi
|
|
|
|
- ok = true
|
|
|
|
- index = it.impl.index
|
|
|
|
- it.impl.index += 1
|
|
|
|
- }
|
|
|
|
|
|
+ it.impl.prev_fi = {}
|
|
|
|
|
|
- if !win32.FindNextFileW(it.impl.find_handle, &it.impl.find_data) {
|
|
|
|
- e := _get_platform_error()
|
|
|
|
- if pe, _ := is_platform_error(e); pe == i32(win32.ERROR_NO_MORE_FILES) {
|
|
|
|
|
|
+ fi, err = find_data_to_file_info(it.impl.path, &it.impl.find_data, file_allocator())
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if fi.name != "" {
|
|
|
|
+ it.impl.prev_fi = fi
|
|
|
|
+ ok = true
|
|
|
|
+ index = it.impl.index
|
|
|
|
+ it.impl.index += 1
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if !win32.FindNextFileW(it.impl.find_handle, &it.impl.find_data) {
|
|
|
|
+ e := _get_platform_error()
|
|
|
|
+ if pe, _ := is_platform_error(e); pe == i32(win32.ERROR_NO_MORE_FILES) {
|
|
|
|
+ it.impl.no_more_files = true
|
|
|
|
+ }
|
|
it.impl.no_more_files = true
|
|
it.impl.no_more_files = true
|
|
}
|
|
}
|
|
- it.impl.no_more_files = true
|
|
|
|
- return
|
|
|
|
|
|
+ if ok {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -94,6 +81,7 @@ _read_directory_iterator_create :: proc(f: ^File) -> (it: Read_Directory_Iterato
|
|
if f == nil {
|
|
if f == nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ it.f = f
|
|
impl := (^File_Impl)(f.impl)
|
|
impl := (^File_Impl)(f.impl)
|
|
|
|
|
|
if !is_directory(impl.name) {
|
|
if !is_directory(impl.name) {
|