file_util_icu.h revision c7f5f8508d98d5952d42ed7648c2a8f30a4da156
1// Copyright (c) 2009 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// File utilities that use the ICU library go in this file.
6
7#include <string>
8
9#include "base/file_path.h"
10#include "base/string16.h"
11
12class FilePath;
13
14namespace file_util {
15
16// Returns true if file_name does not have any illegal character. The input
17// param has the same restriction as that for ReplaceIllegalCharacters.
18bool IsFilenameLegal(const string16& file_name);
19
20// Replaces characters in 'file_name' that are illegal for file names with
21// 'replace_char'. 'file_name' must not be a full or relative path, but just the
22// file name component (since slashes are considered illegal). Any leading or
23// trailing whitespace in 'file_name' is removed.
24// Example:
25//   file_name == "bad:file*name?.txt", changed to: "bad-file-name-.txt" when
26//   'replace_char' is '-'.
27void ReplaceIllegalCharactersInPath(FilePath::StringType* file_name,
28                                    char replace_char);
29
30// Compares two filenames using the current locale information. This can be
31// used to sort directory listings. It behaves like "operator<" for use in
32// std::sort.
33bool LocaleAwareCompareFilenames(const FilePath& a, const FilePath& b);
34
35}  // namespace file_util
36