diff --git a/vlib/os/os_nix.c.v b/vlib/os/os_nix.c.v index 648aa2affc..0766d2af2f 100644 --- a/vlib/os/os_nix.c.v +++ b/vlib/os/os_nix.c.v @@ -211,3 +211,8 @@ pub fn is_writable_folder(folder string) ?bool { os.rm(tmp_perm_check) return true } + +[inline] +pub fn getpid() int { + return C.getpid() +} diff --git a/vlib/os/os_windows.c.v b/vlib/os/os_windows.c.v index 78f4f9bec6..270f093123 100644 --- a/vlib/os/os_windows.c.v +++ b/vlib/os/os_windows.c.v @@ -378,7 +378,7 @@ pub fn is_writable_folder(folder string) ?bool { if !os.is_dir(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 { 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) return true } + +fn C._getpid() int +[inline] +pub fn getpid() int { + return C._getpid() +}