diff --git a/core/os/dir_windows.odin b/core/os/dir_windows.odin index d6028dd7e..f0a1f4ff6 100644 --- a/core/os/dir_windows.odin +++ b/core/os/dir_windows.odin @@ -58,7 +58,7 @@ read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []F dir_fi, _ := file_info_from_get_file_information_by_handle("", h) if !dir_fi.is_dir { - return nil, ERROR_FILE_IS_NOT_DIR + return nil, .Not_Dir } n := n diff --git a/core/os/errors.odin b/core/os/errors.odin index c7fd12dfb..d95c7be51 100644 --- a/core/os/errors.odin +++ b/core/os/errors.odin @@ -32,6 +32,9 @@ General_Error :: enum u32 { Pattern_Has_Separator, Unsupported, + + File_Is_Pipe, + Not_Dir, } @@ -77,6 +80,8 @@ error_string :: proc "contextless" (ferr: Error) -> string { case .Invalid_Callback: return "invalid callback" case .Unsupported: return "unsupported" case .Pattern_Has_Separator: return "pattern has separator" + case .File_Is_Pipe: return "file is pipe" + case .Not_Dir: return "file is not directory" } case io.Error: switch e { diff --git a/core/os/file_windows.odin b/core/os/file_windows.odin index 76f0f2c26..aafe247b3 100644 --- a/core/os/file_windows.odin +++ b/core/os/file_windows.odin @@ -195,7 +195,7 @@ seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Error) { lo := i32(offset) ft := win32.GetFileType(win32.HANDLE(fd)) if ft == win32.FILE_TYPE_PIPE { - return 0, ERROR_FILE_IS_PIPE + return 0, .File_Is_Pipe } dw_ptr := win32.SetFilePointer(win32.HANDLE(fd), lo, &hi, w) @@ -278,7 +278,7 @@ will read from the location twice on *nix, and from two different locations on W */ read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Error) { if offset < 0 { - return 0, ERROR_NEGATIVE_OFFSET + return 0, .Invalid_Offset } b, offset := data, offset @@ -310,7 +310,7 @@ will write to the location twice on *nix, and to two different locations on Wind */ write_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Error) { if offset < 0 { - return 0, ERROR_NEGATIVE_OFFSET + return 0, .Invalid_Offset } b, offset := data, offset diff --git a/core/os/os_js.odin b/core/os/os_js.odin index e14742900..a2ae49b6d 100644 --- a/core/os/os_js.odin +++ b/core/os/os_js.odin @@ -241,10 +241,8 @@ ERROR_PRIVILEGE_NOT_HELD :: Platform_Error.PRIVILEGE_NOT_HELD WSAEACCES :: Platform_Error.WSAEACCES WSAECONNRESET :: Platform_Error.WSAECONNRESET -// Windows reserves errors >= 1<<29 for application use -ERROR_FILE_IS_PIPE :: Platform_Error.FILE_IS_PIPE -ERROR_FILE_IS_NOT_DIR :: Platform_Error.FILE_IS_NOT_DIR -ERROR_NEGATIVE_OFFSET :: Platform_Error.NEGATIVE_OFFSET +ERROR_FILE_IS_PIPE :: General_Error.File_Is_Pipe +ERROR_FILE_IS_NOT_DIR :: General_Error.Not_Dir // "Argv" arguments converted to Odin strings args := _alloc_command_line_arguments() diff --git a/core/os/os_windows.odin b/core/os/os_windows.odin index d331bcfc8..5a080e18c 100644 --- a/core/os/os_windows.odin +++ b/core/os/os_windows.odin @@ -54,10 +54,8 @@ ERROR_PRIVILEGE_NOT_HELD :: _Platform_Error(1314) WSAEACCES :: _Platform_Error(10013) WSAECONNRESET :: _Platform_Error(10054) -// Windows reserves errors >= 1<<29 for application use -ERROR_FILE_IS_PIPE :: _Platform_Error(1<<29 + 0) -ERROR_FILE_IS_NOT_DIR :: _Platform_Error(1<<29 + 1) -ERROR_NEGATIVE_OFFSET :: _Platform_Error(1<<29 + 2) +ERROR_FILE_IS_PIPE :: General_Error.File_Is_Pipe +ERROR_FILE_IS_NOT_DIR :: General_Error.Not_Dir // "Argv" arguments converted to Odin strings args := _alloc_command_line_arguments()