| 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 <io.h> | 7 #include <io.h> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 create_flags |= FILE_ATTRIBUTE_HIDDEN; | 77 create_flags |= FILE_ATTRIBUTE_HIDDEN; |
| 78 if (flags & FLAG_DELETE_ON_CLOSE) | 78 if (flags & FLAG_DELETE_ON_CLOSE) |
| 79 create_flags |= FILE_FLAG_DELETE_ON_CLOSE; | 79 create_flags |= FILE_FLAG_DELETE_ON_CLOSE; |
| 80 if (flags & FLAG_BACKUP_SEMANTICS) | 80 if (flags & FLAG_BACKUP_SEMANTICS) |
| 81 create_flags |= FILE_FLAG_BACKUP_SEMANTICS; | 81 create_flags |= FILE_FLAG_BACKUP_SEMANTICS; |
| 82 | 82 |
| 83 file_.Set(CreateFile(name.value().c_str(), access, sharing, NULL, | 83 file_.Set(CreateFile(name.value().c_str(), access, sharing, NULL, |
| 84 disposition, create_flags, NULL)); | 84 disposition, create_flags, NULL)); |
| 85 | 85 |
| 86 if (file_.IsValid()) { | 86 if (file_.IsValid()) { |
| 87 error_ = FILE_OK; | 87 error_details_ = FILE_OK; |
| 88 async_ = ((flags & FLAG_ASYNC) == FLAG_ASYNC); | 88 async_ = ((flags & FLAG_ASYNC) == FLAG_ASYNC); |
| 89 | 89 |
| 90 if (flags & (FLAG_OPEN_ALWAYS)) | 90 if (flags & (FLAG_OPEN_ALWAYS)) |
| 91 created_ = (ERROR_ALREADY_EXISTS != GetLastError()); | 91 created_ = (ERROR_ALREADY_EXISTS != GetLastError()); |
| 92 else if (flags & (FLAG_CREATE_ALWAYS | FLAG_CREATE)) | 92 else if (flags & (FLAG_CREATE_ALWAYS | FLAG_CREATE)) |
| 93 created_ = true; | 93 created_ = true; |
| 94 } else { | 94 } else { |
| 95 error_ = OSErrorToFileError(GetLastError()); | 95 error_details_ = OSErrorToFileError(GetLastError()); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool File::IsValid() const { | 99 bool File::IsValid() const { |
| 100 return file_.IsValid(); | 100 return file_.IsValid(); |
| 101 } | 101 } |
| 102 PlatformFile File::TakePlatformFile() { | 102 PlatformFile File::TakePlatformFile() { |
| 103 return file_.Take(); | 103 return file_.Take(); |
| 104 } | 104 } |
| 105 | 105 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 last_error); | 323 last_error); |
| 324 return FILE_ERROR_FAILED; | 324 return FILE_ERROR_FAILED; |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 | 327 |
| 328 void File::SetPlatformFile(PlatformFile file) { | 328 void File::SetPlatformFile(PlatformFile file) { |
| 329 file_.Set(file); | 329 file_.Set(file); |
| 330 } | 330 } |
| 331 | 331 |
| 332 } // namespace base | 332 } // namespace base |
| OLD | NEW |