Skip to content

Commit

Permalink
fix -cstrict
Browse files Browse the repository at this point in the history
  • Loading branch information
kbkpbot committed Feb 2, 2025
1 parent 6cd8253 commit 90da7da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion vlib/builtin/cfns.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ fn C.stat(&char, voidptr) int

fn C.lstat(path &char, buf &C.stat) int

fn C.statvfs(const_path &char, buf &C.statvfs) int

fn C.rename(old_filename &char, new_filename &char) int

fn C.fgets(str &char, n int, stream &C.FILE) int
Expand Down Expand Up @@ -514,4 +516,4 @@ fn C.WrappedNSLog(str &u8)
@[trusted]
fn C.abs(number int) int

fn C.GetDiskFreeSpaceExA(path charptr, free_bytes_available_to_caller &u64, total_number_of_bytes &u64, total_number_of_free_bytes &u64) bool
fn C.GetDiskFreeSpaceExA(const_path &char, free_bytes_available_to_caller &u64, total_number_of_bytes &u64, total_number_of_free_bytes &u64) bool
4 changes: 1 addition & 3 deletions vlib/os/os_nix.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -539,15 +539,13 @@ struct C.statvfs {
f_bavail usize
}

fn C.statvfs(path charptr, vfs &C.statvfs) int

// disk_usage returns disk usage of `path`
@[manualfree]
pub fn disk_usage(path string) !DiskUsage {
mpath := if path == '' { '.' } else { path }
defer { unsafe { mpath.free() } }
mut vfs := C.statvfs{}
ret := C.statvfs(mpath.str, &vfs)
ret := unsafe { C.statvfs(&char(mpath.str), &vfs) }
if ret == -1 {
return error('can\`t get disk usage of path')
}
Expand Down
7 changes: 4 additions & 3 deletions vlib/os/os_windows.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,11 @@ pub fn disk_usage(path string) !DiskUsage {
mut available := u64(0)
mut ret := false
if path == '.' || path == '' {
ret = C.GetDiskFreeSpaceExA(0, &free_bytes_available_to_caller, &total, &available)
} else {
ret = C.GetDiskFreeSpaceExA(path.str, &free_bytes_available_to_caller, &total,
ret = C.GetDiskFreeSpaceExA(&char(0), &free_bytes_available_to_caller, &total,
&available)
} else {
ret = C.GetDiskFreeSpaceExA(&char(path.str), &free_bytes_available_to_caller,
&total, &available)
}
if ret == false {
return error('can\`t get disk usage of path')
Expand Down

0 comments on commit 90da7da

Please sign in to comment.