| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/gn/source_file.h" | 5 #include "tools/gn/source_file.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
| 10 #include "tools/gn/source_dir.h" | 10 #include "tools/gn/source_dir.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 SourceFile::SourceFile() { | 26 SourceFile::SourceFile() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 SourceFile::SourceFile(const base::StringPiece& p) | 29 SourceFile::SourceFile(const base::StringPiece& p) |
| 30 : value_(p.data(), p.size()) { | 30 : value_(p.data(), p.size()) { |
| 31 DCHECK(!value_.empty()); | 31 DCHECK(!value_.empty()); |
| 32 AssertValueSourceFileString(value_); | 32 AssertValueSourceFileString(value_); |
| 33 NormalizePath(&value_); |
| 33 } | 34 } |
| 34 | 35 |
| 35 SourceFile::SourceFile(SwapIn, std::string* value) { | 36 SourceFile::SourceFile(SwapIn, std::string* value) { |
| 36 value_.swap(*value); | 37 value_.swap(*value); |
| 37 DCHECK(!value_.empty()); | 38 DCHECK(!value_.empty()); |
| 38 AssertValueSourceFileString(value_); | 39 AssertValueSourceFileString(value_); |
| 40 NormalizePath(&value_); |
| 39 } | 41 } |
| 40 | 42 |
| 41 SourceFile::~SourceFile() { | 43 SourceFile::~SourceFile() { |
| 42 } | 44 } |
| 43 | 45 |
| 44 std::string SourceFile::GetName() const { | 46 std::string SourceFile::GetName() const { |
| 45 if (is_null()) | 47 if (is_null()) |
| 46 return std::string(); | 48 return std::string(); |
| 47 | 49 |
| 48 DCHECK(value_.find('/') != std::string::npos); | 50 DCHECK(value_.find('/') != std::string::npos); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 74 } | 76 } |
| 75 return base::FilePath(UTF8ToFilePath(converted)); | 77 return base::FilePath(UTF8ToFilePath(converted)); |
| 76 } | 78 } |
| 77 | 79 |
| 78 converted.assign(&value_[2], value_.size() - 2); | 80 converted.assign(&value_[2], value_.size() - 2); |
| 79 if (source_root.empty()) | 81 if (source_root.empty()) |
| 80 return UTF8ToFilePath(converted).NormalizePathSeparatorsTo('/'); | 82 return UTF8ToFilePath(converted).NormalizePathSeparatorsTo('/'); |
| 81 return source_root.Append(UTF8ToFilePath(converted)) | 83 return source_root.Append(UTF8ToFilePath(converted)) |
| 82 .NormalizePathSeparatorsTo('/'); | 84 .NormalizePathSeparatorsTo('/'); |
| 83 } | 85 } |
| OLD | NEW |