os: fix some C compiler warnings for windows (#10506)
parent
d56ae2d508
commit
acf9d168cb
|
@ -246,7 +246,7 @@ fn C.RegSetValueExW(hKey voidptr, lpValueName &u16, Reserved u32, dwType u32, lp
|
||||||
|
|
||||||
fn C.RegCloseKey(hKey voidptr)
|
fn C.RegCloseKey(hKey voidptr)
|
||||||
|
|
||||||
fn C.RemoveDirectory(lpPathName &char) int
|
fn C.RemoveDirectory(lpPathName &u16) int
|
||||||
|
|
||||||
// fn C.GetStdHandle() voidptr
|
// fn C.GetStdHandle() voidptr
|
||||||
fn C.GetStdHandle(u32) voidptr
|
fn C.GetStdHandle(u32) voidptr
|
||||||
|
|
|
@ -29,7 +29,7 @@ fn C.CopyFile(&u16, &u16, bool) int
|
||||||
|
|
||||||
// fn C.lstat(charptr, voidptr) u64
|
// fn C.lstat(charptr, voidptr) u64
|
||||||
|
|
||||||
fn C._wstat64(&char, voidptr) u64
|
fn C._wstat64(&u16, voidptr) u64
|
||||||
|
|
||||||
fn C.chown(&char, int, int) int
|
fn C.chown(&char, int, int) int
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ pub fn file_size(path string) u64 {
|
||||||
$if x64 {
|
$if x64 {
|
||||||
$if windows {
|
$if windows {
|
||||||
mut swin := C.__stat64{}
|
mut swin := C.__stat64{}
|
||||||
if C._wstat64(&char(path.to_wide()), voidptr(&swin)) != 0 {
|
if C._wstat64(path.to_wide(), voidptr(&swin)) != 0 {
|
||||||
eprintln_unknown_file_size()
|
eprintln_unknown_file_size()
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ pub fn rm(path string) ? {
|
||||||
// rmdir removes a specified directory.
|
// rmdir removes a specified directory.
|
||||||
pub fn rmdir(path string) ? {
|
pub fn rmdir(path string) ? {
|
||||||
$if windows {
|
$if windows {
|
||||||
rc := C.RemoveDirectory(&char(path.to_wide()))
|
rc := C.RemoveDirectory(path.to_wide())
|
||||||
if rc == 0 {
|
if rc == 0 {
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-removedirectorya - 0 is failure
|
// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-removedirectorya - 0 is failure
|
||||||
return error('Failed to remove "$path": ' + posix_get_error_msg(C.errno))
|
return error('Failed to remove "$path": ' + posix_get_error_msg(C.errno))
|
||||||
|
@ -777,12 +777,11 @@ pub fn getwd() string {
|
||||||
// NB: this particular rabbit hole is *deep* ...
|
// NB: this particular rabbit hole is *deep* ...
|
||||||
[manualfree]
|
[manualfree]
|
||||||
pub fn real_path(fpath string) string {
|
pub fn real_path(fpath string) string {
|
||||||
mut fullpath := &byte(0)
|
|
||||||
mut res := ''
|
mut res := ''
|
||||||
$if windows {
|
$if windows {
|
||||||
// GetFullPathName doesn't work with symbolic links,
|
// GetFullPathName doesn't work with symbolic links,
|
||||||
// so if it is not a file, get full path
|
// so if it is not a file, get full path
|
||||||
fullpath = unsafe { &u16(vcalloc_noscan(max_path_len * 2)) }
|
mut fullpath := unsafe { &u16(vcalloc_noscan(max_path_len * 2)) }
|
||||||
// TODO: check errors if path len is not enough
|
// TODO: check errors if path len is not enough
|
||||||
ret := C.GetFullPathName(fpath.to_wide(), max_path_len, fullpath, 0)
|
ret := C.GetFullPathName(fpath.to_wide(), max_path_len, fullpath, 0)
|
||||||
if ret == 0 {
|
if ret == 0 {
|
||||||
|
@ -791,7 +790,7 @@ pub fn real_path(fpath string) string {
|
||||||
}
|
}
|
||||||
res = unsafe { string_from_wide(fullpath) }
|
res = unsafe { string_from_wide(fullpath) }
|
||||||
} $else {
|
} $else {
|
||||||
fullpath = vcalloc_noscan(max_path_len)
|
mut fullpath := vcalloc_noscan(max_path_len)
|
||||||
ret := &char(C.realpath(&char(fpath.str), &char(fullpath)))
|
ret := &char(C.realpath(&char(fpath.str), &char(fullpath)))
|
||||||
if ret == 0 {
|
if ret == 0 {
|
||||||
unsafe { free(fullpath) }
|
unsafe { free(fullpath) }
|
||||||
|
|
Loading…
Reference in New Issue