mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: mkdir() error handling
This commit is contained in:

committed by
Alexander Medvednikov

parent
0fb0c43c0a
commit
3a6ccf7f31
@ -61,12 +61,14 @@ pub fn dir_exists(path string) bool {
|
||||
}
|
||||
|
||||
// mkdir creates a new directory with the specified path.
|
||||
pub fn mkdir(path string) {
|
||||
//$if linux {
|
||||
//C.syscall(83, path.str, 511) // sys_mkdir
|
||||
//} $else {
|
||||
C.mkdir(path.str, 511)// S_IRWXU | S_IRWXG | S_IRWXO
|
||||
//}
|
||||
pub fn mkdir(path string) ?bool {
|
||||
if path == '.' { return true }
|
||||
apath := os.realpath( path )
|
||||
r := int(C.mkdir(apath.str, 511))
|
||||
if r == -1 {
|
||||
return error(get_error_msg(C.errno))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// exec starts the specified command, waits for it to complete, and returns its output.
|
||||
|
Reference in New Issue
Block a user