| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <fnmatch.h> | 8 #include <fnmatch.h> |
| 9 #include <fts.h> | 9 #include <fts.h> |
| 10 #include <libgen.h> | 10 #include <libgen.h> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 bool CopyTree(const std::wstring& from_path, const std::wstring& to_path) { | 104 bool CopyTree(const std::wstring& from_path, const std::wstring& to_path) { |
| 105 // TODO(erikkay): implement | 105 // TODO(erikkay): implement |
| 106 return false; | 106 return false; |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool PathExists(const std::wstring& path) { | 109 bool PathExists(const std::wstring& path) { |
| 110 struct stat64 file_info; | 110 struct stat64 file_info; |
| 111 return (stat64(WideToUTF8(path).c_str(), &file_info) == 0); | 111 return (stat64(WideToUTF8(path).c_str(), &file_info) == 0); |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool DirectoryExists(const std::wstring& path) { |
| 115 struct stat64 file_info; |
| 116 if (stat64(WideToUTF8(path).c_str(), &file_info) == 0) |
| 117 return S_ISDIR(file_info.st_mode); |
| 118 return false; |
| 119 } |
| 120 |
| 114 // TODO(erikkay): implement | 121 // TODO(erikkay): implement |
| 115 #if 0 | 122 #if 0 |
| 116 bool GetFileCreationLocalTimeFromHandle(int fd, | 123 bool GetFileCreationLocalTimeFromHandle(int fd, |
| 117 LPSYSTEMTIME creation_time) { | 124 LPSYSTEMTIME creation_time) { |
| 118 if (!file_handle) | 125 if (!file_handle) |
| 119 return false; | 126 return false; |
| 120 | 127 |
| 121 FILETIME utc_filetime; | 128 FILETIME utc_filetime; |
| 122 if (!GetFileTime(file_handle, &utc_filetime, NULL, NULL)) | 129 if (!GetFileTime(file_handle, &utc_filetime, NULL, NULL)) |
| 123 return false; | 130 return false; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 bool CreateDirectory(const std::wstring& full_path) { | 179 bool CreateDirectory(const std::wstring& full_path) { |
| 173 std::vector<std::wstring> components; | 180 std::vector<std::wstring> components; |
| 174 PathComponents(full_path, &components); | 181 PathComponents(full_path, &components); |
| 175 std::wstring path; | 182 std::wstring path; |
| 176 std::vector<std::wstring>::iterator i = components.begin(); | 183 std::vector<std::wstring>::iterator i = components.begin(); |
| 177 for (; i != components.end(); ++i) { | 184 for (; i != components.end(); ++i) { |
| 178 if (path.length() == 0) | 185 if (path.length() == 0) |
| 179 path = *i; | 186 path = *i; |
| 180 else | 187 else |
| 181 AppendToPath(&path, *i); | 188 AppendToPath(&path, *i); |
| 182 if (!PathExists(path)) { | 189 if (!DirectoryExists(path)) { |
| 183 if (mkdir(WideToUTF8(path).c_str(), 0777) != 0) | 190 if (mkdir(WideToUTF8(path).c_str(), 0777) != 0) |
| 184 return false; | 191 return false; |
| 185 } | 192 } |
| 186 } | 193 } |
| 187 return true; | 194 return true; |
| 188 } | 195 } |
| 189 | 196 |
| 190 bool GetFileSize(const std::wstring& file_path, int64* file_size) { | 197 bool GetFileSize(const std::wstring& file_path, int64* file_size) { |
| 191 struct stat64 file_info; | 198 struct stat64 file_info; |
| 192 if (stat64(WideToUTF8(file_path).c_str(), &file_info) != 0) | 199 if (stat64(WideToUTF8(file_path).c_str(), &file_info) != 0) |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 return (file_type_ & FileEnumerator::DIRECTORIES) ? cur_file : Next(); | 324 return (file_type_ & FileEnumerator::DIRECTORIES) ? cur_file : Next(); |
| 318 } else if (fts_ent->fts_info == FTS_F) { | 325 } else if (fts_ent->fts_info == FTS_F) { |
| 319 return (file_type_ & FileEnumerator::FILES) ? cur_file : Next(); | 326 return (file_type_ & FileEnumerator::FILES) ? cur_file : Next(); |
| 320 } | 327 } |
| 321 // TODO(erikkay) - verify that the other fts_info types aren't interesting | 328 // TODO(erikkay) - verify that the other fts_info types aren't interesting |
| 322 return Next(); | 329 return Next(); |
| 323 } | 330 } |
| 324 | 331 |
| 325 | 332 |
| 326 } // namespace file_util | 333 } // namespace file_util |
| 327 | |
| 328 | |
| OLD | NEW |