| Index: chrome/browser/local_discovery/storage/path_util.cc
|
| diff --git a/chrome/browser/local_discovery/storage/path_util.cc b/chrome/browser/local_discovery/storage/path_util.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..947672bd7d01d01c622d57468cf0fba45dce23c2
|
| --- /dev/null
|
| +++ b/chrome/browser/local_discovery/storage/path_util.cc
|
| @@ -0,0 +1,45 @@
|
| +// Copyright 2014 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 "chrome/browser/local_discovery/storage/path_util.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| +
|
| +namespace local_discovery {
|
| +
|
| +namespace {
|
| +
|
| +const int kNumComponentsInBasePrivetPath = 4;
|
| +const int kIndexOfServiceNameInComponentList = 2;
|
| +
|
| +std::string PathStringToString(const base::FilePath::StringType& string) {
|
| +#if defined(OS_WIN)
|
| + return base::UTF16ToUTF8(string);
|
| +#else
|
| + return string;
|
| +#endif
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +ParsedPrivetPath::ParsedPrivetPath(const base::FilePath& file_path) {
|
| + std::vector<base::FilePath::StringType> components;
|
| + file_path.GetComponents(&components);
|
| + DCHECK(components.size() >= kNumComponentsInBasePrivetPath);
|
| + service_name = PathStringToString(
|
| + components[kIndexOfServiceNameInComponentList]);
|
| +
|
| +
|
| + for (uint i = kNumComponentsInBasePrivetPath; i < components.size(); i++) {
|
| + path += '/' + PathStringToString(components[i]);
|
| + }
|
| +
|
| + if (path.empty()) path = "/";
|
| +}
|
| +
|
| +ParsedPrivetPath::~ParsedPrivetPath() {
|
| +}
|
| +
|
| +} // namespace local_discovery
|
|
|