| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/sync/util/path_helpers.h" | 5 #include "chrome/browser/sync/util/path_helpers.h" |
| 6 | 6 |
| 7 #include <Shlwapi.h> | 7 #include <Shlwapi.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/port.h" | 11 #include "base/port.h" |
| 12 #include "build/build_config.h" |
| 12 #include "chrome/browser/sync/syncable/syncable.h" | 13 #include "chrome/browser/sync/syncable/syncable.h" |
| 13 | 14 |
| 14 #ifndef OS_WINDOWS | 15 #ifndef OS_WIN |
| 15 #error Compile this file on Windows only. | 16 #error Compile this file on Windows only. |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 18 using std::string; | 19 using std::string; |
| 19 | 20 |
| 20 #if OS_WINDOWS | 21 #if OS_WIN |
| 21 const char PATH_SEPARATOR = '\\'; | 22 const char PATH_SEPARATOR = '\\'; |
| 22 #else | 23 #else |
| 23 const char PATH_SEPARATOR = '/'; | 24 const char PATH_SEPARATOR = '/'; |
| 24 #endif // OS_WINDOWS | 25 #endif // OS_WIN |
| 25 | 26 |
| 26 | 27 |
| 27 static PathString RemoveTrailingSlashes16(PathString str) { | 28 static PathString RemoveTrailingSlashes16(PathString str) { |
| 28 while ((str.length() > 0) && (str.at(str.length() - 1) == kPathSeparator[0])) | 29 while ((str.length() > 0) && (str.at(str.length() - 1) == kPathSeparator[0])) |
| 29 str.resize(str.length() - 1); | 30 str.resize(str.length() - 1); |
| 30 return str; | 31 return str; |
| 31 } | 32 } |
| 32 | 33 |
| 33 static string RemoveTrailingSlashes(string str) { | 34 static string RemoveTrailingSlashes(string str) { |
| 34 while ((str.length() > 0) && (str.at(str.length() - 1) == PATH_SEPARATOR)) | 35 while ((str.length() > 0) && (str.at(str.length() - 1) == PATH_SEPARATOR)) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 145 } |
| 145 if ((L"" == sub) && (L"" == postsub)) { | 146 if ((L"" == sub) && (L"" == postsub)) { |
| 146 sub = L"~1"; | 147 sub = L"~1"; |
| 147 } | 148 } |
| 148 | 149 |
| 149 // Return the new name, only if it differs from the original. | 150 // Return the new name, only if it differs from the original. |
| 150 if ((sub + postsub) == component) | 151 if ((sub + postsub) == component) |
| 151 return L""; | 152 return L""; |
| 152 return (sub + postsub); | 153 return (sub + postsub); |
| 153 } | 154 } |
| OLD | NEW |