diff options
author | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-23 22:00:04 +0000 |
---|---|---|
committer | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-23 22:00:04 +0000 |
commit | b2f2308d0c635418caa3ad2a2560a2778d70a4d5 (patch) | |
tree | daaa5177eb28ddcb2d5582a4e78cf7b0318aea07 /base/platform_file_posix.cc | |
parent | 10b6e62953ff6ebc0ac9e7cb7628677da273f79b (diff) | |
download | chromium_src-b2f2308d0c635418caa3ad2a2560a2778d70a4d5.zip chromium_src-b2f2308d0c635418caa3ad2a2560a2778d70a4d5.tar.gz chromium_src-b2f2308d0c635418caa3ad2a2560a2778d70a4d5.tar.bz2 |
Fix PP_FileOpenFlags_Dev handling:
- rewrite the mapping from PP_FileOpenFlags_Dev to PlatformFileFlags.
- let ppb_flash_file_impl and ppb_file_io_impl use the same mapping logic.
- CreatePlatformFile: resolve the conflict between the win and posix implementation. Before this change, the win implementation didn't allow PLATFORM_FILE_TRUNCATE to be used with any of the (OPEN|CREATE)(_ALWAYS)? flags; while the posix implementation required it to be used with them.
- add more test cases to test the behavior of different PP_FileOpenFlags_Dev combinations.
- also unify the conversion from PlatformFileError to Pepper error.
BUG=68489
TEST=New test cases in test_file_io.cc
Review URL: http://codereview.chromium.org/7038032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86349 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/platform_file_posix.cc')
-rw-r--r-- | base/platform_file_posix.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc index 2ffac06..a1388d6 100644 --- a/base/platform_file_posix.cc +++ b/base/platform_file_posix.cc @@ -44,6 +44,12 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags, open_flags = O_CREAT | O_TRUNC; } + if (flags & PLATFORM_FILE_OPEN_TRUNCATED) { + DCHECK(!open_flags); + DCHECK(flags & PLATFORM_FILE_WRITE); + open_flags = O_TRUNC; + } + if (!open_flags && !(flags & PLATFORM_FILE_OPEN) && !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { NOTREACHED(); @@ -62,11 +68,6 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags, NOTREACHED(); } - if (flags & PLATFORM_FILE_TRUNCATE) { - DCHECK(flags & PLATFORM_FILE_WRITE); - open_flags |= O_TRUNC; - } - COMPILE_ASSERT(O_RDONLY == 0, O_RDONLY_must_equal_zero); int descriptor = |