mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
os: vfmt most of os
, add it to v test-cleancode
This commit is contained in:
parent
525b521b4a
commit
88a8507dd8
14 changed files with 208 additions and 276 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue