Browse Source

Add `Fstat_Callback` for `File.user_fstat`

gingerBill 1 year ago
parent
commit
59c33dd9fc
2 changed files with 7 additions and 1 deletions
  1. 2 1
      core/os/os2/file.odin
  2. 5 0
      core/os/os2/stat.odin

+ 2 - 1
core/os/os2/file.odin

@@ -5,8 +5,9 @@ import "core:time"
 import "base:runtime"
 
 File :: struct {
-	impl: _File,
+	impl:   _File,
 	stream: io.Stream,
+	user_fstat: Fstat_Callback,
 }
 
 File_Mode :: distinct u32

+ 5 - 0
core/os/os2/stat.odin

@@ -3,6 +3,8 @@ package os2
 import "core:time"
 import "base:runtime"
 
+Fstat_Callback :: proc(f: ^File, allocator: runtime.Allocator) -> (File_Info, Error)
+
 File_Info :: struct {
 	fullpath:          string,
 	name:              string,
@@ -27,6 +29,9 @@ file_info_delete :: proc(fi: File_Info, allocator: runtime.Allocator) {
 
 @(require_results)
 fstat :: proc(f: ^File, allocator: runtime.Allocator) -> (File_Info, Error) {
+	if f != nil && f.user_fstat != nil {
+		return f->user_fstat(allocator)
+	}
 	return _fstat(f, allocator)
 }