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 #ifndef TOOLS_GN_SOURCE_DIR_H_ | 5 #ifndef TOOLS_GN_SOURCE_DIR_H_ |
6 #define TOOLS_GN_SOURCE_DIR_H_ | 6 #define TOOLS_GN_SOURCE_DIR_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 // Swaps the given string in without copies. The given string will be empty | 31 // Swaps the given string in without copies. The given string will be empty |
32 // after this call. | 32 // after this call. |
33 SourceDir(SwapIn, std::string* s); | 33 SourceDir(SwapIn, std::string* s); |
34 ~SourceDir(); | 34 ~SourceDir(); |
35 | 35 |
36 // Resolves a file or dir name relative to this source directory. Will return | 36 // Resolves a file or dir name relative to this source directory. Will return |
37 // an empty SourceDir/File on error. Empty input is always an error (it's | 37 // an empty SourceDir/File on error. Empty input is always an error (it's |
38 // possible we should say ResolveRelativeDir vs. an empty string should be | 38 // possible we should say ResolveRelativeDir vs. an empty string should be |
39 // the source dir, but we require "." instead). | 39 // the source dir, but we require "." instead). |
40 // | 40 // |
41 // If source_root is supplied, these functions will additionally handle the | 41 // If |source_root| is non-empty, these functions will additionally handle the |
42 // case where the input is a system-absolute but still inside the source | 42 // case where the input is a system-absolute but still inside the source |
43 // tree. This is the case for some external tools. | 43 // tree. This is the case for some external tools. |
44 SourceFile ResolveRelativeFile( | 44 SourceFile ResolveRelativeFile(const base::StringPiece& p, |
45 const base::StringPiece& p, | 45 const base::FilePath& source_root) const; |
46 const base::StringPiece& source_root = base::StringPiece()) const; | 46 SourceDir ResolveRelativeDir(const base::StringPiece& p, |
47 SourceDir ResolveRelativeDir( | 47 const base::FilePath& source_root) const; |
48 const base::StringPiece& p, | |
49 const base::StringPiece& source_root = base::StringPiece()) const; | |
50 | 48 |
51 // Resolves this source file relative to some given source root. Returns | 49 // Resolves this source file relative to some given source root. Returns |
52 // an empty file path on error. | 50 // an empty file path on error. |
53 base::FilePath Resolve(const base::FilePath& source_root) const; | 51 base::FilePath Resolve(const base::FilePath& source_root) const; |
54 | 52 |
55 bool is_null() const { return value_.empty(); } | 53 bool is_null() const { return value_.empty(); } |
56 const std::string& value() const { return value_; } | 54 const std::string& value() const { return value_; } |
57 | 55 |
58 // Returns true if this path starts with a "//" which indicates a path | 56 // Returns true if this path starts with a "//" which indicates a path |
59 // from the source root. | 57 // from the source root. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 115 } |
118 #endif // COMPILER... | 116 #endif // COMPILER... |
119 | 117 |
120 } // namespace BASE_HASH_NAMESPACE | 118 } // namespace BASE_HASH_NAMESPACE |
121 | 119 |
122 inline void swap(SourceDir& lhs, SourceDir& rhs) { | 120 inline void swap(SourceDir& lhs, SourceDir& rhs) { |
123 lhs.swap(rhs); | 121 lhs.swap(rhs); |
124 } | 122 } |
125 | 123 |
126 #endif // TOOLS_GN_SOURCE_DIR_H_ | 124 #endif // TOOLS_GN_SOURCE_DIR_H_ |
OLD | NEW |