Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Side by Side Diff: chrome/browser/local_discovery/storage/path_util.cc

Issue 141703022: Support for file listing in privet local filesystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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 "chrome/browser/local_discovery/storage/path_util.h"
6
7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h"
9
10 namespace local_discovery {
11
12 namespace {
13
14 const int kNumComponentsInBasePrivetPath = 4;
15 const int kIndexOfServiceNameInComponentList = 2;
16
17 std::string PathStringToString(const base::FilePath::StringType& string) {
18 #if defined(OS_WIN)
19 return base::UTF16ToUTF8(string);
20 #else
21 return string;
22 #endif
23 }
24
25 } // namespace
26
27 ParsedPrivetPath::ParsedPrivetPath(const base::FilePath& file_path) {
28 std::vector<base::FilePath::StringType> components;
29 file_path.GetComponents(&components);
30 DCHECK(components.size() >= kNumComponentsInBasePrivetPath);
31 service_name = PathStringToString(
32 components[kIndexOfServiceNameInComponentList]);
33
34
35 for (uint i = kNumComponentsInBasePrivetPath; i < components.size(); i++) {
36 path += '/' + PathStringToString(components[i]);
37 }
38
39 if (path.empty()) path = "/";
40 }
41
42 ParsedPrivetPath::~ParsedPrivetPath() {
43 }
44
45 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698