blob: 851e8682fe88de52f22590e3970be32cfde6fd98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright (c) 2009 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 <sys/types.h>
#include <string.h>
#include "base/logging.h"
#include "base/port.h"
#include "chrome/browser/sync/util/character_set_converters.h"
#include "chrome/browser/sync/util/path_helpers.h"
#ifndef OS_LINUX
#error Compile this file on Linux only.
#endif
string LastPathSegment(const string& path) {
string str(path);
string::size_type final_slash = str.find_last_of('/');
if (string::npos != final_slash && final_slash == str.length() - 1
&& str.length() > 1) {
str.erase(final_slash);
final_slash = str.find_last_of('/');
}
if (string::npos == final_slash)
return str;
str.erase(0, final_slash + 1);
return str;
}
PathString GetFullPath(const PathString& path) {
// TODO(sync): Not sure what the base of the relative path should be on
// linux.
return path;
}
PathString AppendSlash(const PathString& path) {
if ((!path.empty()) && (*path.rbegin() != '/')) {
return path + '/';
}
return path;
}
|