Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: base/files/file_posix.cc

Issue 314023002: Require FLAG_WRITE when FLAG_CREATE_ALWAYS is specified (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PlatformFile.CreatePlatformFile test Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/files/file_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/file.h" 5 #include "base/files/file.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 DCHECK(!IsValid()); 176 DCHECK(!IsValid());
177 177
178 int open_flags = 0; 178 int open_flags = 0;
179 if (flags & FLAG_CREATE) 179 if (flags & FLAG_CREATE)
180 open_flags = O_CREAT | O_EXCL; 180 open_flags = O_CREAT | O_EXCL;
181 181
182 created_ = false; 182 created_ = false;
183 183
184 if (flags & FLAG_CREATE_ALWAYS) { 184 if (flags & FLAG_CREATE_ALWAYS) {
185 DCHECK(!open_flags); 185 DCHECK(!open_flags);
186 DCHECK(flags & FLAG_WRITE);
rvargas (doing something else) 2014/06/05 19:27:52 We should keep the behavior consistent across plat
mdempsky 2014/06/09 17:56:22 Done.
186 open_flags = O_CREAT | O_TRUNC; 187 open_flags = O_CREAT | O_TRUNC;
187 } 188 }
188 189
189 if (flags & FLAG_OPEN_TRUNCATED) { 190 if (flags & FLAG_OPEN_TRUNCATED) {
190 DCHECK(!open_flags); 191 DCHECK(!open_flags);
191 DCHECK(flags & FLAG_WRITE); 192 DCHECK(flags & FLAG_WRITE);
192 open_flags = O_TRUNC; 193 open_flags = O_TRUNC;
193 } 194 }
194 195
195 if (!open_flags && !(flags & FLAG_OPEN) && !(flags & FLAG_OPEN_ALWAYS)) { 196 if (!open_flags && !(flags & FLAG_OPEN) && !(flags & FLAG_OPEN_ALWAYS)) {
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 return FILE_ERROR_FAILED; 479 return FILE_ERROR_FAILED;
479 } 480 }
480 } 481 }
481 482
482 void File::SetPlatformFile(PlatformFile file) { 483 void File::SetPlatformFile(PlatformFile file) {
483 DCHECK(!file_.is_valid()); 484 DCHECK(!file_.is_valid());
484 file_.reset(file); 485 file_.reset(file);
485 } 486 }
486 487
487 } // namespace base 488 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/files/file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698