1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os: fix some C compiler warnings for windows (#10506)

This commit is contained in:
Bastian Buck 2021-06-18 19:07:25 +02:00 committed by GitHub
parent d56ae2d508
commit acf9d168cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -246,7 +246,7 @@ fn C.RegSetValueExW(hKey voidptr, lpValueName &u16, Reserved u32, dwType u32, lp
fn C.RegCloseKey(hKey voidptr)
fn C.RemoveDirectory(lpPathName &char) int
fn C.RemoveDirectory(lpPathName &u16) int
// fn C.GetStdHandle() voidptr
fn C.GetStdHandle(u32) voidptr

View File

@ -29,7 +29,7 @@ fn C.CopyFile(&u16, &u16, bool) int
// 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
@ -168,7 +168,7 @@ pub fn file_size(path string) u64 {
$if x64 {
$if windows {
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()
return 0
}
@ -471,7 +471,7 @@ pub fn rm(path string) ? {
// rmdir removes a specified directory.
pub fn rmdir(path string) ? {
$if windows {
rc := C.RemoveDirectory(&char(path.to_wide()))
rc := C.RemoveDirectory(path.to_wide())
if rc == 0 {
// 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))
@ -777,12 +777,11 @@ pub fn getwd() string {
// NB: this particular rabbit hole is *deep* ...
[manualfree]
pub fn real_path(fpath string) string {
mut fullpath := &byte(0)
mut res := ''
$if windows {
// GetFullPathName doesn't work with symbolic links,
// 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
ret := C.GetFullPathName(fpath.to_wide(), max_path_len, fullpath, 0)
if ret == 0 {
@ -791,7 +790,7 @@ pub fn real_path(fpath string) string {
}
res = unsafe { string_from_wide(fullpath) }
} $else {
fullpath = vcalloc_noscan(max_path_len)
mut fullpath := vcalloc_noscan(max_path_len)
ret := &char(C.realpath(&char(fpath.str), &char(fullpath)))
if ret == 0 {
unsafe { free(fullpath) }