| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 recursive); | 379 recursive); |
| 380 } | 380 } |
| 381 bool Delete(const std::wstring& path, bool recursive) { | 381 bool Delete(const std::wstring& path, bool recursive) { |
| 382 return Delete(FilePath::FromWStringHack(path), recursive); | 382 return Delete(FilePath::FromWStringHack(path), recursive); |
| 383 } | 383 } |
| 384 std::wstring GetFileExtensionFromPath(const std::wstring& path) { | 384 std::wstring GetFileExtensionFromPath(const std::wstring& path) { |
| 385 FilePath::StringType extension = | 385 FilePath::StringType extension = |
| 386 GetFileExtensionFromPath(FilePath::FromWStringHack(path)); | 386 GetFileExtensionFromPath(FilePath::FromWStringHack(path)); |
| 387 return extension; | 387 return extension; |
| 388 } | 388 } |
| 389 std::wstring GetFilenameFromPath(const std::wstring& path) { | |
| 390 if (path.empty() || EndsWithSeparator(FilePath::FromWStringHack(path))) | |
| 391 return std::wstring(); | |
| 392 | |
| 393 return FilePath::FromWStringHack(path).BaseName().ToWStringHack(); | |
| 394 } | |
| 395 FILE* OpenFile(const std::wstring& filename, const char* mode) { | 389 FILE* OpenFile(const std::wstring& filename, const char* mode) { |
| 396 return OpenFile(FilePath::FromWStringHack(filename), mode); | 390 return OpenFile(FilePath::FromWStringHack(filename), mode); |
| 397 } | 391 } |
| 398 int ReadFile(const std::wstring& filename, char* data, int size) { | 392 int ReadFile(const std::wstring& filename, char* data, int size) { |
| 399 return ReadFile(FilePath::FromWStringHack(filename), data, size); | 393 return ReadFile(FilePath::FromWStringHack(filename), data, size); |
| 400 } | 394 } |
| 401 int WriteFile(const std::wstring& filename, const char* data, int size) { | 395 int WriteFile(const std::wstring& filename, const char* data, int size) { |
| 402 return WriteFile(FilePath::FromWStringHack(filename), data, size); | 396 return WriteFile(FilePath::FromWStringHack(filename), data, size); |
| 403 } | 397 } |
| 404 #endif // OS_WIN | 398 #endif // OS_WIN |
| 405 | 399 |
| 406 /////////////////////////////////////////////// | 400 /////////////////////////////////////////////// |
| 407 // FileEnumerator | 401 // FileEnumerator |
| 408 // | 402 // |
| 409 // Note: the main logic is in file_util_<platform>.cc | 403 // Note: the main logic is in file_util_<platform>.cc |
| 410 | 404 |
| 411 bool FileEnumerator::ShouldSkip(const FilePath& path) { | 405 bool FileEnumerator::ShouldSkip(const FilePath& path) { |
| 412 FilePath::StringType basename = path.BaseName().value(); | 406 FilePath::StringType basename = path.BaseName().value(); |
| 413 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); | 407 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); |
| 414 } | 408 } |
| 415 | 409 |
| 416 } // namespace | 410 } // namespace |
| OLD | NEW |