stat.odin 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package os2
  2. import "core:time"
  3. import "base:runtime"
  4. Fstat_Callback :: proc(f: ^File, allocator: runtime.Allocator) -> (File_Info, Error)
  5. File_Info :: struct {
  6. fullpath: string,
  7. name: string,
  8. size: i64,
  9. mode: File_Mode,
  10. is_directory: bool,
  11. creation_time: time.Time,
  12. modification_time: time.Time,
  13. access_time: time.Time,
  14. }
  15. file_info_slice_delete :: proc(infos: []File_Info, allocator: runtime.Allocator) {
  16. for i := len(infos)-1; i >= 0; i -= 1 {
  17. file_info_delete(infos[i], allocator)
  18. }
  19. delete(infos, allocator)
  20. }
  21. file_info_delete :: proc(fi: File_Info, allocator: runtime.Allocator) {
  22. delete(fi.fullpath, allocator)
  23. }
  24. @(require_results)
  25. fstat :: proc(f: ^File, allocator: runtime.Allocator) -> (File_Info, Error) {
  26. if f != nil && f.user_fstat != nil {
  27. return f->user_fstat(allocator)
  28. }
  29. return _fstat(f, allocator)
  30. }
  31. @(require_results)
  32. stat :: proc(name: string, allocator: runtime.Allocator) -> (File_Info, Error) {
  33. return _stat(name, allocator)
  34. }
  35. lstat :: stat_do_not_follow_links
  36. @(require_results)
  37. stat_do_not_follow_links :: proc(name: string, allocator: runtime.Allocator) -> (File_Info, Error) {
  38. return _lstat(name, allocator)
  39. }
  40. @(require_results)
  41. same_file :: proc(fi1, fi2: File_Info) -> bool {
  42. return _same_file(fi1, fi2)
  43. }