split file path constants out for split link

This is a follow on of work started in https://codereview.chromium.org/15310002/

TBR=brettw@chromium.org
R=cpu@chromium.org
BUG=237249

Review URL: https://chromiumcodereview.appspot.com/15495003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201279 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: f39e0381ea6e83c74d149fd3afda84dbf64a1681
diff --git a/base/files/file_path.cc b/base/files/file_path.cc
index 03ccbcd..a9e4be2 100644
--- a/base/files/file_path.cc
+++ b/base/files/file_path.cc
@@ -31,17 +31,6 @@
 
 namespace base {
 
-#if defined(FILE_PATH_USES_WIN_SEPARATORS)
-const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("\\/");
-#else  // FILE_PATH_USES_WIN_SEPARATORS
-const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("/");
-#endif  // FILE_PATH_USES_WIN_SEPARATORS
-
-const FilePath::CharType FilePath::kCurrentDirectory[] = FILE_PATH_LITERAL(".");
-const FilePath::CharType FilePath::kParentDirectory[] = FILE_PATH_LITERAL("..");
-
-const FilePath::CharType FilePath::kExtensionSeparator = FILE_PATH_LITERAL('.');
-
 typedef FilePath::StringType StringType;
 
 namespace {
@@ -139,7 +128,7 @@
       path.rfind(FilePath::kExtensionSeparator, last_dot - 1);
   const StringType::size_type last_separator =
       path.find_last_of(FilePath::kSeparators, last_dot - 1,
-                        arraysize(FilePath::kSeparators) - 1);
+                        FilePath::kSeparatorsLength - 1);
 
   if (penultimate_dot == StringType::npos ||
       (last_separator != StringType::npos &&
@@ -217,7 +206,7 @@
 
 // static
 bool FilePath::IsSeparator(CharType character) {
-  for (size_t i = 0; i < arraysize(kSeparators) - 1; ++i) {
+  for (size_t i = 0; i < kSeparatorsLength - 1; ++i) {
     if (character == kSeparators[i]) {
       return true;
     }
@@ -325,7 +314,7 @@
 
   StringType::size_type last_separator =
       new_path.path_.find_last_of(kSeparators, StringType::npos,
-                                  arraysize(kSeparators) - 1);
+                                  kSeparatorsLength - 1);
   if (last_separator == StringType::npos) {
     // path_ is in the current directory.
     new_path.path_.resize(letter + 1);
@@ -363,7 +352,7 @@
   // one character and it's a separator, leave it alone.
   StringType::size_type last_separator =
       new_path.path_.find_last_of(kSeparators, StringType::npos,
-                                  arraysize(kSeparators) - 1);
+                                  kSeparatorsLength - 1);
   if (last_separator != StringType::npos &&
       last_separator < new_path.path_.length() - 1) {
     new_path.path_.erase(0, last_separator + 1);
@@ -1269,7 +1258,7 @@
 FilePath FilePath::NormalizePathSeparators() const {
 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
   StringType copy = path_;
-  for (size_t i = 1; i < arraysize(kSeparators); ++i) {
+  for (size_t i = 1; i < kSeparatorsLength; ++i) {
     std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]);
   }
   return FilePath(copy);
diff --git a/base/files/file_path.h b/base/files/file_path.h
index d66d631..d7e134e 100644
--- a/base/files/file_path.h
+++ b/base/files/file_path.h
@@ -150,6 +150,9 @@
   // when composing pathnames.
   static const CharType kSeparators[];
 
+  // arraysize(kSeparators).
+  static const size_t kSeparatorsLength;
+
   // A special path component meaning "this directory."
   static const CharType kCurrentDirectory[];
 
diff --git a/base/files/file_path_constants.cc b/base/files/file_path_constants.cc
new file mode 100644
index 0000000..34b17a6
--- /dev/null
+++ b/base/files/file_path_constants.cc
@@ -0,0 +1,22 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/files/file_path.h"
+
+namespace base {
+
+#if defined(FILE_PATH_USES_WIN_SEPARATORS)
+const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("\\/");
+#else  // FILE_PATH_USES_WIN_SEPARATORS
+const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("/");
+#endif  // FILE_PATH_USES_WIN_SEPARATORS
+
+const size_t FilePath::kSeparatorsLength = arraysize(kSeparators);
+
+const FilePath::CharType FilePath::kCurrentDirectory[] = FILE_PATH_LITERAL(".");
+const FilePath::CharType FilePath::kParentDirectory[] = FILE_PATH_LITERAL("..");
+
+const FilePath::CharType FilePath::kExtensionSeparator = FILE_PATH_LITERAL('.');
+
+}  // namespace base