| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/filesystem/directory_impl.h" | 5 #include "components/filesystem/directory_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 | 64 |
| 65 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
| 66 // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory. | 66 // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory. |
| 67 if (DirectoryExists(path)) | 67 if (DirectoryExists(path)) |
| 68 open_flags |= base::File::FLAG_BACKUP_SEMANTICS; | 68 open_flags |= base::File::FLAG_BACKUP_SEMANTICS; |
| 69 #endif // OS_WIN | 69 #endif // OS_WIN |
| 70 | 70 |
| 71 base::File base_file(path, open_flags); | 71 base::File base_file(path, open_flags); |
| 72 if (!base_file.IsValid()) { | 72 if (!base_file.IsValid()) { |
| 73 callback.Run(FileError::FAILED); | 73 callback.Run(GetError(base_file)); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 | 76 |
| 77 base::File::Info info; | 77 base::File::Info info; |
| 78 if (!base_file.GetInfo(&info)) { | 78 if (!base_file.GetInfo(&info)) { |
| 79 callback.Run(FileError::FAILED); | 79 callback.Run(FileError::FAILED); |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 | 82 |
| 83 if (info.is_directory) { | 83 if (info.is_directory) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 callback.Run(error, false); | 196 callback.Run(error, false); |
| 197 return; | 197 return; |
| 198 } | 198 } |
| 199 | 199 |
| 200 callback.Run(FileError::OK, base::PathIsWritable(path)); | 200 callback.Run(FileError::OK, base::PathIsWritable(path)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void DirectoryImpl::Flush(const FlushCallback& callback) { | 203 void DirectoryImpl::Flush(const FlushCallback& callback) { |
| 204 base::File file(directory_path_, base::File::FLAG_READ); | 204 base::File file(directory_path_, base::File::FLAG_READ); |
| 205 if (!file.IsValid()) { | 205 if (!file.IsValid()) { |
| 206 callback.Run(FileError::FAILED); | 206 callback.Run(GetError(file)); |
| 207 return; | 207 return; |
| 208 } | 208 } |
| 209 | 209 |
| 210 if (!file.Flush()) { | 210 if (!file.Flush()) { |
| 211 callback.Run(FileError::FAILED); | 211 callback.Run(FileError::FAILED); |
| 212 return; | 212 return; |
| 213 } | 213 } |
| 214 | 214 |
| 215 callback.Run(FileError::OK); | 215 callback.Run(FileError::OK); |
| 216 } | 216 } |
| 217 | 217 |
| 218 } // namespace filesystem | 218 } // namespace filesystem |
| OLD | NEW |