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_FILESYSTEM_UTILS_H_ | 5 #ifndef TOOLS_GN_FILESYSTEM_UTILS_H_ |
6 #define TOOLS_GN_FILESYSTEM_UTILS_H_ | 6 #define TOOLS_GN_FILESYSTEM_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // empty substring if none. For example "//foo/bar/" -> "bar". | 97 // empty substring if none. For example "//foo/bar/" -> "bar". |
98 base::StringPiece FindLastDirComponent(const SourceDir& dir); | 98 base::StringPiece FindLastDirComponent(const SourceDir& dir); |
99 | 99 |
100 // Verifies that the given string references a file inside of the given | 100 // Verifies that the given string references a file inside of the given |
101 // directory. This is pretty stupid and doesn't handle "." and "..", etc., | 101 // directory. This is pretty stupid and doesn't handle "." and "..", etc., |
102 // it is designed for a sanity check to keep people from writing output files | 102 // it is designed for a sanity check to keep people from writing output files |
103 // to the source directory accidentally. | 103 // to the source directory accidentally. |
104 // | 104 // |
105 // The originating value will be blamed in the error. | 105 // The originating value will be blamed in the error. |
106 // | 106 // |
| 107 // Setting allow_templates indicates that the result will be put into a |
| 108 // FileTemplate and it will allow the strings to be prefixed with expansions |
| 109 // that would include the output path. |
| 110 // |
107 // If the file isn't in the dir, returns false and sets the error. Otherwise | 111 // If the file isn't in the dir, returns false and sets the error. Otherwise |
108 // returns true and leaves the error untouched. | 112 // returns true and leaves the error untouched. |
109 bool EnsureStringIsInOutputDir(const SourceDir& dir, | 113 bool EnsureStringIsInOutputDir(const SourceDir& dir, |
110 const std::string& str, | 114 const std::string& str, |
111 const Value& originating, | 115 const Value& originating, |
| 116 bool allow_templates, |
112 Err* err); | 117 Err* err); |
113 | 118 |
114 // ---------------------------------------------------------------------------- | 119 // ---------------------------------------------------------------------------- |
115 | 120 |
116 // Returns true if the input string is absolute. Double-slashes at the | 121 // Returns true if the input string is absolute. Double-slashes at the |
117 // beginning are treated as source-relative paths. On Windows, this handles | 122 // beginning are treated as source-relative paths. On Windows, this handles |
118 // paths of both the native format: "C:/foo" and ours "/C:/foo" | 123 // paths of both the native format: "C:/foo" and ours "/C:/foo" |
119 bool IsPathAbsolute(const base::StringPiece& path); | 124 bool IsPathAbsolute(const base::StringPiece& path); |
120 | 125 |
121 // Given an absolute path, checks to see if is it is inside the source root. | 126 // Given an absolute path, checks to see if is it is inside the source root. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 SourceDir GetOutputDirForSourceDir(const Settings* settings, | 189 SourceDir GetOutputDirForSourceDir(const Settings* settings, |
185 const SourceDir& source_dir); | 190 const SourceDir& source_dir); |
186 SourceDir GetGenDirForSourceDir(const Settings* settings, | 191 SourceDir GetGenDirForSourceDir(const Settings* settings, |
187 const SourceDir& source_dir); | 192 const SourceDir& source_dir); |
188 SourceDir GetTargetOutputDir(const Target* target); | 193 SourceDir GetTargetOutputDir(const Target* target); |
189 SourceDir GetTargetGenDir(const Target* target); | 194 SourceDir GetTargetGenDir(const Target* target); |
190 SourceDir GetCurrentOutputDir(const Scope* scope); | 195 SourceDir GetCurrentOutputDir(const Scope* scope); |
191 SourceDir GetCurrentGenDir(const Scope* scope); | 196 SourceDir GetCurrentGenDir(const Scope* scope); |
192 | 197 |
193 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ | 198 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ |
OLD | NEW |