OLD | NEW |
(Empty) | |
| 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 #include <sys/types.h> |
| 6 |
| 7 #include <glib.h> |
| 8 #include <string.h> |
| 9 |
| 10 #include "base/logging.h" |
| 11 #include "base/port.h" |
| 12 #include "chrome/browser/sync/util/character_set_converters.h" |
| 13 #include "chrome/browser/sync/util/path_helpers.h" |
| 14 |
| 15 #ifndef OS_LINUX |
| 16 #error Compile this file on Linux only. |
| 17 #endif |
| 18 |
| 19 string LastPathSegment(const string& path) { |
| 20 string str(path); |
| 21 string::size_type final_slash = str.find_last_of('/'); |
| 22 if (string::npos != final_slash && final_slash == str.length() - 1 |
| 23 && str.length() > 1) { |
| 24 str.erase(final_slash); |
| 25 final_slash = str.find_last_of('/'); |
| 26 } |
| 27 if (string::npos == final_slash) |
| 28 return str; |
| 29 str.erase(0, final_slash+1); |
| 30 return str; |
| 31 } |
| 32 |
| 33 PathString GetFullPath(const PathString& path) { |
| 34 // TODO(sync): Not sure what the base of the relative path should be on |
| 35 // linux. |
| 36 return path; |
| 37 } |
| 38 |
| 39 PathString AppendSlash(const PathString& path) { |
| 40 if ((!path.empty()) && (*path.rbegin() != '/')) { |
| 41 return path + '/'; |
| 42 } |
| 43 return path; |
| 44 } |
| 45 |
| 46 PathString LowercasePath(const PathString& path) { |
| 47 gchar *ret = g_utf8_strdown(path.c_str(), -1); |
| 48 PathString retstr(ret); |
| 49 g_free(ret); |
| 50 return retstr; |
| 51 } |
OLD | NEW |