Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |