| OLD | NEW |
| 1 // Copyright (c) 2009 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 #ifndef BASE_I18N_FILE_UTIL_ICU_H_ | 5 #ifndef BASE_I18N_FILE_UTIL_ICU_H_ |
| 6 #define BASE_I18N_FILE_UTIL_ICU_H_ | 6 #define BASE_I18N_FILE_UTIL_ICU_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 // File utilities that use the ICU library go in this file. | 9 // File utilities that use the ICU library go in this file. |
| 10 | 10 |
| 11 #include <string> | |
| 12 | |
| 13 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 14 #include "base/string16.h" | 12 #include "base/string16.h" |
| 15 | 13 |
| 16 class FilePath; | 14 class FilePath; |
| 17 | 15 |
| 18 namespace file_util { | 16 namespace file_util { |
| 19 | 17 |
| 20 // Returns true if file_name does not have any illegal character. The input | 18 // Returns true if file_name does not have any illegal character. The input |
| 21 // param has the same restriction as that for ReplaceIllegalCharacters. | 19 // param has the same restriction as that for ReplaceIllegalCharacters. |
| 22 bool IsFilenameLegal(const string16& file_name); | 20 bool IsFilenameLegal(const string16& file_name); |
| 23 | 21 |
| 24 // Replaces characters in 'file_name' that are illegal for file names with | 22 // Replaces characters in 'file_name' that are illegal for file names with |
| 25 // 'replace_char'. 'file_name' must not be a full or relative path, but just the | 23 // 'replace_char'. 'file_name' must not be a full or relative path, but just the |
| 26 // file name component (since slashes are considered illegal). Any leading or | 24 // file name component (since slashes are considered illegal). Any leading or |
| 27 // trailing whitespace in 'file_name' is removed. | 25 // trailing whitespace in 'file_name' is removed. |
| 28 // Example: | 26 // Example: |
| 29 // file_name == "bad:file*name?.txt", changed to: "bad-file-name-.txt" when | 27 // file_name == "bad:file*name?.txt", changed to: "bad-file-name-.txt" when |
| 30 // 'replace_char' is '-'. | 28 // 'replace_char' is '-'. |
| 31 void ReplaceIllegalCharactersInPath(FilePath::StringType* file_name, | 29 void ReplaceIllegalCharactersInPath(FilePath::StringType* file_name, |
| 32 char replace_char); | 30 char replace_char); |
| 33 | 31 |
| 34 // Compares two filenames using the current locale information. This can be | 32 // Compares two filenames using the current locale information. This can be |
| 35 // used to sort directory listings. It behaves like "operator<" for use in | 33 // used to sort directory listings. It behaves like "operator<" for use in |
| 36 // std::sort. | 34 // std::sort. |
| 37 bool LocaleAwareCompareFilenames(const FilePath& a, const FilePath& b); | 35 bool LocaleAwareCompareFilenames(const FilePath& a, const FilePath& b); |
| 38 | 36 |
| 39 } // namespace file_util | 37 } // namespace file_util |
| 40 | 38 |
| 41 #endif // BASE_I18N_FILE_UTIL_ICU_H_ | 39 #endif // BASE_I18N_FILE_UTIL_ICU_H_ |
| OLD | NEW |