diff options
Diffstat (limited to 'base/platform_file_posix.cc')
-rw-r--r-- | base/platform_file_posix.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc index dd1c78d..f964c62 100644 --- a/base/platform_file_posix.cc +++ b/base/platform_file_posix.cc @@ -52,6 +52,10 @@ PlatformFile CreatePlatformFile(const std::wstring& name, *created = false; } else { open_flags |= O_CREAT; + if (flags & PLATFORM_FILE_EXCLUSIVE_READ || + flags & PLATFORM_FILE_EXCLUSIVE_WRITE) { + open_flags |= O_EXCL; // together with O_CREAT implies O_NOFOLLOW + } descriptor = open(WideToUTF8(name).c_str(), open_flags, S_IRUSR | S_IWUSR); if (created && descriptor > 0) @@ -59,7 +63,15 @@ PlatformFile CreatePlatformFile(const std::wstring& name, } } + if ((descriptor > 0) && (flags & PLATFORM_FILE_DELETE_ON_CLOSE)) { + unlink(WideToUTF8(name).c_str()); + } + return descriptor; } +bool ClosePlatformFile(PlatformFile file) { + return close(file); +} + } // namespace base |