| OLD | NEW |
| (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 |
| OLD | NEW |