mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 05:08:14 +00:00
Minimize unneeded casts
This commit is contained in:
@@ -27,7 +27,7 @@ open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errn
|
||||
access |= win32.FILE_GENERIC_WRITE;
|
||||
}
|
||||
|
||||
share_mode := u32(win32.FILE_SHARE_READ|win32.FILE_SHARE_WRITE);
|
||||
share_mode := win32.FILE_SHARE_READ|win32.FILE_SHARE_WRITE;
|
||||
sa: ^win32.SECURITY_ATTRIBUTES = nil;
|
||||
sa_inherit := win32.SECURITY_ATTRIBUTES{nLength = size_of(win32.SECURITY_ATTRIBUTES), bInheritHandle = true};
|
||||
if mode&O_CLOEXEC == 0 {
|
||||
@@ -48,7 +48,7 @@ open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errn
|
||||
create_mode = win32.OPEN_EXISTING;
|
||||
}
|
||||
wide_path := win32.utf8_to_wstring(path);
|
||||
handle := Handle(win32.CreateFileW(auto_cast wide_path, access, share_mode, sa, create_mode, win32.FILE_ATTRIBUTE_NORMAL|win32.FILE_FLAG_BACKUP_SEMANTICS, nil));
|
||||
handle := Handle(win32.CreateFileW(wide_path, access, share_mode, sa, create_mode, win32.FILE_ATTRIBUTE_NORMAL|win32.FILE_FLAG_BACKUP_SEMANTICS, nil));
|
||||
if handle != INVALID_HANDLE {
|
||||
return handle, ERROR_NONE;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ read :: proc(fd: Handle, data: []byte) -> (int, Errno) {
|
||||
|
||||
for total_read < length {
|
||||
remaining := length - total_read;
|
||||
to_read := win32.DWORD(min(u32(remaining), MAX_RW));
|
||||
to_read := min(win32.DWORD(remaining), MAX_RW);
|
||||
|
||||
e := win32.ReadFile(win32.HANDLE(fd), &data[total_read], to_read, &single_read_length, nil);
|
||||
if single_read_length <= 0 || !e {
|
||||
|
||||
@@ -79,7 +79,7 @@ last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) {
|
||||
data: win32.WIN32_FILE_ATTRIBUTE_DATA;
|
||||
|
||||
wide_path := win32.utf8_to_wstring(name);
|
||||
if !win32.GetFileAttributesExW(auto_cast wide_path, win32.GetFileExInfoStandard, &data) {
|
||||
if !win32.GetFileAttributesExW(wide_path, win32.GetFileExInfoStandard, &data) {
|
||||
return 0, Errno(win32.GetLastError());
|
||||
}
|
||||
|
||||
|
||||
@@ -68,13 +68,13 @@ _stat :: proc(name: string, create_file_attributes: u32, allocator := context.al
|
||||
|
||||
|
||||
lstat :: proc(name: string, allocator := context.allocator) -> (File_Info, Errno) {
|
||||
attrs := u32(win32.FILE_FLAG_BACKUP_SEMANTICS);
|
||||
attrs := win32.FILE_FLAG_BACKUP_SEMANTICS;
|
||||
attrs |= win32.FILE_FLAG_OPEN_REPARSE_POINT;
|
||||
return _stat(name, attrs, allocator);
|
||||
}
|
||||
|
||||
stat :: proc(name: string, allocator := context.allocator) -> (File_Info, Errno) {
|
||||
attrs := u32(win32.FILE_FLAG_BACKUP_SEMANTICS);
|
||||
attrs := win32.FILE_FLAG_BACKUP_SEMANTICS;
|
||||
return _stat(name, attrs, allocator);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user