os: vfmt most of os, add it to v test-cleancode

This commit is contained in:
Delyan Angelov 2020-12-16 11:02:36 +02:00
parent 525b521b4a
commit 88a8507dd8
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
14 changed files with 208 additions and 276 deletions

View file

@ -15,16 +15,16 @@ enum FileType {
struct FilePermission {
pub:
read bool
write bool
read bool
write bool
execute bool
}
struct FileMode {
pub:
typ FileType
owner FilePermission
group FilePermission
typ FileType
owner FilePermission
group FilePermission
others FilePermission
}
@ -32,10 +32,7 @@ pub:
// it supports windows for regular files but it doesn't matter if you use owner, group or others when checking permissions on windows
pub fn inode(path string) FileMode {
mut attr := C.stat{}
unsafe {
C.stat(charptr(path.str), &attr)
}
unsafe {C.stat(charptr(path.str), &attr)}
mut typ := FileType.regular
if attr.st_mode & u32(C.S_IFMT) == u32(C.S_IFDIR) {
typ = .directory
@ -53,7 +50,6 @@ pub fn inode(path string) FileMode {
typ = .socket
}
}
$if windows {
return FileMode{
typ: typ