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 29 matching lines...) Expand all Loading... |
40 if (EndsWithSeparator(*path)) | 40 if (EndsWithSeparator(*path)) |
41 return true; | 41 return true; |
42 | 42 |
43 FilePath::StringType& path_str = | 43 FilePath::StringType& path_str = |
44 const_cast<FilePath::StringType&>(path->value()); | 44 const_cast<FilePath::StringType&>(path->value()); |
45 path_str.append(&FilePath::kSeparators[0], 1); | 45 path_str.append(&FilePath::kSeparators[0], 1); |
46 | 46 |
47 return true; | 47 return true; |
48 } | 48 } |
49 | 49 |
50 void TrimTrailingSeparator(std::wstring* dir) { | |
51 while (dir->length() > 1 && EndsWithSeparator(dir)) | |
52 dir->resize(dir->length() - 1); | |
53 } | |
54 | |
55 FilePath::StringType GetFileExtensionFromPath(const FilePath& path) { | 50 FilePath::StringType GetFileExtensionFromPath(const FilePath& path) { |
56 FilePath::StringType file_name = path.BaseName().value(); | 51 FilePath::StringType file_name = path.BaseName().value(); |
57 const FilePath::StringType::size_type last_dot = | 52 const FilePath::StringType::size_type last_dot = |
58 file_name.rfind(kExtensionSeparator); | 53 file_name.rfind(kExtensionSeparator); |
59 return FilePath::StringType(last_dot == FilePath::StringType::npos ? | 54 return FilePath::StringType(last_dot == FilePath::StringType::npos ? |
60 FILE_PATH_LITERAL("") : | 55 FILE_PATH_LITERAL("") : |
61 file_name, last_dot+1); | 56 file_name, last_dot+1); |
62 } | 57 } |
63 | 58 |
64 void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix) { | 59 void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix) { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 434 |
440 bool FileEnumerator::IsDot(const FilePath& path) { | 435 bool FileEnumerator::IsDot(const FilePath& path) { |
441 return FILE_PATH_LITERAL(".") == path.BaseName().value(); | 436 return FILE_PATH_LITERAL(".") == path.BaseName().value(); |
442 } | 437 } |
443 | 438 |
444 bool FileEnumerator::IsDotDot(const FilePath& path) { | 439 bool FileEnumerator::IsDotDot(const FilePath& path) { |
445 return FILE_PATH_LITERAL("..") == path.BaseName().value(); | 440 return FILE_PATH_LITERAL("..") == path.BaseName().value(); |
446 } | 441 } |
447 | 442 |
448 } // namespace | 443 } // namespace |
OLD | NEW |