diff options
author | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 21:58:28 +0000 |
---|---|---|
committer | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 21:58:28 +0000 |
commit | ee8d4c8656fc8a8723e91e44d05fba4027c77b66 (patch) | |
tree | 7ed5dd75b40690657edd1e41b1aa78a980fd43d2 /base | |
parent | 0189bc72c90fab03afab623d0b2d8be3d35af3e7 (diff) | |
download | chromium_src-ee8d4c8656fc8a8723e91e44d05fba4027c77b66.zip chromium_src-ee8d4c8656fc8a8723e91e44d05fba4027c77b66.tar.gz chromium_src-ee8d4c8656fc8a8723e91e44d05fba4027c77b66.tar.bz2 |
Chromium side patch for DB support on Linux.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/174232
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24807 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/platform_file.h | 7 | ||||
-rw-r--r-- | base/platform_file_posix.cc | 12 | ||||
-rw-r--r-- | base/platform_file_win.cc | 4 |
3 files changed, 21 insertions, 2 deletions
diff --git a/base/platform_file.h b/base/platform_file.h index a584d42..5d84262 100644 --- a/base/platform_file.h +++ b/base/platform_file.h @@ -34,16 +34,19 @@ enum PlatformFileFlags { PLATFORM_FILE_ASYNC = 256, PLATFORM_FILE_TEMPORARY = 512, // Used on Windows only PLATFORM_FILE_HIDDEN = 1024, // Used on Windows only - PLATFORM_FILE_DELETE_ON_CLOSE = 2048 // Used on Windows only + PLATFORM_FILE_DELETE_ON_CLOSE = 2048 }; -// Creates or open the given file. If PLATFORM_FILE_OPEN_ALWAYS is used, and +// Creates or opens the given file. If PLATFORM_FILE_OPEN_ALWAYS is used, and // |created| is provided, |created| will be set to true if the file was created // or to false in case the file was just opened. PlatformFile CreatePlatformFile(const std::wstring& name, int flags, bool* created); +// Closes a file handle +bool ClosePlatformFile(PlatformFile file); + } // namespace base #endif // BASE_PLATFORM_FILE_H_ 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 diff --git a/base/platform_file_win.cc b/base/platform_file_win.cc index b389a16..06e6200 100644 --- a/base/platform_file_win.cc +++ b/base/platform_file_win.cc @@ -65,4 +65,8 @@ PlatformFile CreatePlatformFile(const std::wstring& name, return file; } +bool ClosePlatformFile(PlatformFile file) { + return (CloseHandle(file) == 0); +} + } // namespace disk_cache |