| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #endif | 9 #endif |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 return ReadFileToString(FilePath::FromWStringHack(path), contents); | 324 return ReadFileToString(FilePath::FromWStringHack(path), contents); |
| 325 } | 325 } |
| 326 | 326 |
| 327 bool AbsolutePath(std::wstring* path_str) { | 327 bool AbsolutePath(std::wstring* path_str) { |
| 328 FilePath path(FilePath::FromWStringHack(*path_str)); | 328 FilePath path(FilePath::FromWStringHack(*path_str)); |
| 329 if (!AbsolutePath(&path)) | 329 if (!AbsolutePath(&path)) |
| 330 return false; | 330 return false; |
| 331 *path_str = path.ToWStringHack(); | 331 *path_str = path.ToWStringHack(); |
| 332 return true; | 332 return true; |
| 333 } | 333 } |
| 334 |
| 335 #if defined(OS_WIN) |
| 336 // This function is deprecated; see file_util_deprecated.h for details. |
| 334 void AppendToPath(std::wstring* path, const std::wstring& new_ending) { | 337 void AppendToPath(std::wstring* path, const std::wstring& new_ending) { |
| 335 if (!path) { | 338 if (!path) { |
| 336 NOTREACHED(); | 339 NOTREACHED(); |
| 337 return; // Don't crash in this function in release builds. | 340 return; // Don't crash in this function in release builds. |
| 338 } | 341 } |
| 339 | 342 |
| 340 if (!EndsWithSeparator(path)) | 343 if (!EndsWithSeparator(*path)) |
| 341 path->push_back(FilePath::kSeparators[0]); | 344 path->push_back(FilePath::kSeparators[0]); |
| 342 path->append(new_ending); | 345 path->append(new_ending); |
| 343 } | 346 } |
| 347 #endif |
| 348 |
| 344 bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path, | 349 bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path, |
| 345 bool recursive) { | 350 bool recursive) { |
| 346 return CopyDirectory(FilePath::FromWStringHack(from_path), | 351 return CopyDirectory(FilePath::FromWStringHack(from_path), |
| 347 FilePath::FromWStringHack(to_path), | 352 FilePath::FromWStringHack(to_path), |
| 348 recursive); | 353 recursive); |
| 349 } | 354 } |
| 350 bool Delete(const std::wstring& path, bool recursive) { | 355 bool Delete(const std::wstring& path, bool recursive) { |
| 351 return Delete(FilePath::FromWStringHack(path), recursive); | 356 return Delete(FilePath::FromWStringHack(path), recursive); |
| 352 } | 357 } |
| 353 bool EndsWithSeparator(std::wstring* path) { | |
| 354 return EndsWithSeparator(FilePath::FromWStringHack(*path)); | |
| 355 } | |
| 356 bool EndsWithSeparator(const std::wstring& path) { | 358 bool EndsWithSeparator(const std::wstring& path) { |
| 357 return EndsWithSeparator(FilePath::FromWStringHack(path)); | 359 return EndsWithSeparator(FilePath::FromWStringHack(path)); |
| 358 } | 360 } |
| 359 bool GetCurrentDirectory(std::wstring* path_str) { | 361 bool GetCurrentDirectory(std::wstring* path_str) { |
| 360 FilePath path; | 362 FilePath path; |
| 361 if (!GetCurrentDirectory(&path)) | 363 if (!GetCurrentDirectory(&path)) |
| 362 return false; | 364 return false; |
| 363 *path_str = path.ToWStringHack(); | 365 *path_str = path.ToWStringHack(); |
| 364 return true; | 366 return true; |
| 365 } | 367 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 // FileEnumerator | 425 // FileEnumerator |
| 424 // | 426 // |
| 425 // Note: the main logic is in file_util_<platform>.cc | 427 // Note: the main logic is in file_util_<platform>.cc |
| 426 | 428 |
| 427 bool FileEnumerator::ShouldSkip(const FilePath& path) { | 429 bool FileEnumerator::ShouldSkip(const FilePath& path) { |
| 428 FilePath::StringType basename = path.BaseName().value(); | 430 FilePath::StringType basename = path.BaseName().value(); |
| 429 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); | 431 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); |
| 430 } | 432 } |
| 431 | 433 |
| 432 } // namespace | 434 } // namespace |
| OLD | NEW |