Get env stuff working on Windows

This commit is contained in:
gingerBill
2022-02-21 12:35:52 +00:00
parent 14cb19c2df
commit 345032f804
6 changed files with 112 additions and 86 deletions
+33 -23
View File
@@ -63,31 +63,41 @@ is_platform_error :: proc(ferr: Error) -> (err: i32, ok: bool) {
error_string :: proc(ferr: Error) -> string {
switch ferr {
case nil: return ""
case .Invalid_Argument: return "invalid argument"
case .Permission_Denied: return "permission denied"
case .Exist: return "file already exists"
case .Not_Exist: return "file does not exist"
case .Closed: return "file already closed"
case .Timeout: return "i/o timeout"
case .EOF: return "eof"
case .Unexpected_EOF: return "unexpected eof"
case .Short_Write: return "short write"
case .Invalid_Write: return "invalid write result"
case .Short_Buffer: return "short buffer"
case .No_Progress: return "multiple read calls return no data or error"
case .Invalid_Whence: return "invalid whence"
case .Invalid_Offset: return "invalid offset"
case .Invalid_Unread: return "invalid unread"
case .Negative_Read: return "negative read"
case .Negative_Write: return "negative write"
case .Negative_Count: return "negative count"
case .Buffer_Full: return "buffer full"
@static general_error_strings := [General_Error]string{
.Invalid_Argument = "invalid argument",
.Permission_Denied = "permission denied",
.Exist = "file already exists",
.Not_Exist = "file does not exist",
.Closed = "file already closed",
.Timeout = "i/o timeout",
}
if errno, ok := is_platform_error(ferr); ok {
return _error_string(errno)
@static io_error_strings := [io.Error]string{
.None = "",
.EOF = "eof",
.Unexpected_EOF = "unexpected eof",
.Short_Write = "short write",
.Invalid_Write = "invalid write result",
.Short_Buffer = "short buffer",
.No_Progress = "multiple read calls return no data or error",
.Invalid_Whence = "invalid whence",
.Invalid_Offset = "invalid offset",
.Invalid_Unread = "invalid unread",
.Negative_Read = "negative read",
.Negative_Write = "negative write",
.Negative_Count = "negative count",
.Buffer_Full = "buffer full",
.Unknown = "unknown i/o error",
.Empty = "empty i/o error",
}
if ferr == nil {
return ""
}
switch err in ferr {
case General_Error: return general_error_strings[err]
case io.Error: return io_error_strings[err]
case Platform_Error: return _error_string(err.err)
}
return "unknown error"