os: add os.getpid(), use it in os.is_writable_folder on windows
parent
7b1944c2da
commit
5874d7c5ab
|
@ -211,3 +211,8 @@ pub fn is_writable_folder(folder string) ?bool {
|
||||||
os.rm(tmp_perm_check)
|
os.rm(tmp_perm_check)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[inline]
|
||||||
|
pub fn getpid() int {
|
||||||
|
return C.getpid()
|
||||||
|
}
|
||||||
|
|
|
@ -378,7 +378,7 @@ pub fn is_writable_folder(folder string) ?bool {
|
||||||
if !os.is_dir(folder) {
|
if !os.is_dir(folder) {
|
||||||
return error('`folder` is not a folder')
|
return error('`folder` is not a folder')
|
||||||
}
|
}
|
||||||
tmp_perm_check := os.join_path(folder, 'tmp_perm_check')
|
tmp_perm_check := os.join_path(folder, 'tmp_perm_check_pid_' + getpid().str())
|
||||||
mut f := os.open_file(tmp_perm_check, 'w+', 0o700) or {
|
mut f := os.open_file(tmp_perm_check, 'w+', 0o700) or {
|
||||||
return error('cannot write to folder $folder: $err')
|
return error('cannot write to folder $folder: $err')
|
||||||
}
|
}
|
||||||
|
@ -386,3 +386,9 @@ pub fn is_writable_folder(folder string) ?bool {
|
||||||
os.rm(tmp_perm_check)
|
os.rm(tmp_perm_check)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn C._getpid() int
|
||||||
|
[inline]
|
||||||
|
pub fn getpid() int {
|
||||||
|
return C._getpid()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue