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 // | |
111 // If the file isn't in the dir, returns false and sets the error. Otherwise | 107 // If the file isn't in the dir, returns false and sets the error. Otherwise |
112 // returns true and leaves the error untouched. | 108 // returns true and leaves the error untouched. |
113 bool EnsureStringIsInOutputDir(const SourceDir& dir, | 109 bool EnsureStringIsInOutputDir(const SourceDir& dir, |
114 const std::string& str, | 110 const std::string& str, |
115 const Value& originating, | 111 const Value& originating, |
116 bool allow_templates, | |
117 Err* err); | 112 Err* err); |
118 | 113 |
119 // ---------------------------------------------------------------------------- | 114 // ---------------------------------------------------------------------------- |
120 | 115 |
121 // Returns true if the input string is absolute. Double-slashes at the | 116 // Returns true if the input string is absolute. Double-slashes at the |
122 // beginning are treated as source-relative paths. On Windows, this handles | 117 // beginning are treated as source-relative paths. On Windows, this handles |
123 // paths of both the native format: "C:/foo" and ours "/C:/foo" | 118 // paths of both the native format: "C:/foo" and ours "/C:/foo" |
124 bool IsPathAbsolute(const base::StringPiece& path); | 119 bool IsPathAbsolute(const base::StringPiece& path); |
125 | 120 |
126 // Given an absolute path, checks to see if is it is inside the source root. | 121 // 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... |
189 SourceDir GetOutputDirForSourceDir(const Settings* settings, | 184 SourceDir GetOutputDirForSourceDir(const Settings* settings, |
190 const SourceDir& source_dir); | 185 const SourceDir& source_dir); |
191 SourceDir GetGenDirForSourceDir(const Settings* settings, | 186 SourceDir GetGenDirForSourceDir(const Settings* settings, |
192 const SourceDir& source_dir); | 187 const SourceDir& source_dir); |
193 SourceDir GetTargetOutputDir(const Target* target); | 188 SourceDir GetTargetOutputDir(const Target* target); |
194 SourceDir GetTargetGenDir(const Target* target); | 189 SourceDir GetTargetGenDir(const Target* target); |
195 SourceDir GetCurrentOutputDir(const Scope* scope); | 190 SourceDir GetCurrentOutputDir(const Scope* scope); |
196 SourceDir GetCurrentGenDir(const Scope* scope); | 191 SourceDir GetCurrentGenDir(const Scope* scope); |
197 | 192 |
198 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ | 193 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ |
OLD | NEW |