Allow os.read_dir to use a different allocator

This commit is contained in:
gingerBill
2020-09-27 00:31:29 +01:00
parent 96a0125599
commit 2ebb94fa72

View File

@@ -4,7 +4,7 @@ import win32 "core:sys/windows"
import "core:strings"
import "core:time"
read_dir :: proc(fd: Handle, n: int) -> (fi: []File_Info, err: Errno) {
read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []File_Info, err: Errno) {
find_data_to_file_info :: proc(base_path: string, d: ^win32.WIN32_FIND_DATAW) -> (fi: File_Info) {
// Ignore "." and ".."
if d.cFileName[0] == '.' && d.cFileName[1] == 0 {
@@ -53,6 +53,8 @@ read_dir :: proc(fd: Handle, n: int) -> (fi: []File_Info, err: Errno) {
return nil, ERROR_INVALID_HANDLE;
}
context.allocator = allocator;
h := win32.HANDLE(fd);
dir_fi, _ := stat_from_file_information("", h);