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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // Returns true if the given path ends with a slash. | 85 // Returns true if the given path ends with a slash. |
86 bool EndsWithSlash(const std::string& s); | 86 bool EndsWithSlash(const std::string& s); |
87 | 87 |
88 // Path parts ----------------------------------------------------------------- | 88 // Path parts ----------------------------------------------------------------- |
89 | 89 |
90 // Returns a string piece pointing into the input string identifying the | 90 // Returns a string piece pointing into the input string identifying the |
91 // directory name of the given path, including the last slash. Note that the | 91 // directory name of the given path, including the last slash. Note that the |
92 // input pointer must outlive the output. | 92 // input pointer must outlive the output. |
93 base::StringPiece FindDir(const std::string* path); | 93 base::StringPiece FindDir(const std::string* path); |
94 | 94 |
| 95 // Returns the substring identifying the last component of the dir, or the |
| 96 // empty substring if none. For example "//foo/bar/" -> "bar". |
| 97 base::StringPiece FindLastDirComponent(const SourceDir& dir); |
| 98 |
95 // Verifies that the given string references a file inside of the given | 99 // Verifies that the given string references a file inside of the given |
96 // directory. This is pretty stupid and doesn't handle "." and "..", etc., | 100 // directory. This is pretty stupid and doesn't handle "." and "..", etc., |
97 // it is designed for a sanity check to keep people from writing output files | 101 // it is designed for a sanity check to keep people from writing output files |
98 // to the source directory accidentally. | 102 // to the source directory accidentally. |
99 // | 103 // |
100 // The originating value will be blamed in the error. | 104 // The originating value will be blamed in the error. |
101 // | 105 // |
102 // If the file isn't in the dir, returns false and sets the error. Otherwise | 106 // If the file isn't in the dir, returns false and sets the error. Otherwise |
103 // returns true and leaves the error untouched. | 107 // returns true and leaves the error untouched. |
104 bool EnsureStringIsInOutputDir(const SourceDir& dir, | 108 bool EnsureStringIsInOutputDir(const SourceDir& dir, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 SourceDir GetOutputDirForSourceDir(const Settings* settings, | 173 SourceDir GetOutputDirForSourceDir(const Settings* settings, |
170 const SourceDir& source_dir); | 174 const SourceDir& source_dir); |
171 SourceDir GetGenDirForSourceDir(const Settings* settings, | 175 SourceDir GetGenDirForSourceDir(const Settings* settings, |
172 const SourceDir& source_dir); | 176 const SourceDir& source_dir); |
173 SourceDir GetTargetOutputDir(const Target* target); | 177 SourceDir GetTargetOutputDir(const Target* target); |
174 SourceDir GetTargetGenDir(const Target* target); | 178 SourceDir GetTargetGenDir(const Target* target); |
175 SourceDir GetCurrentOutputDir(const Scope* scope); | 179 SourceDir GetCurrentOutputDir(const Scope* scope); |
176 SourceDir GetCurrentGenDir(const Scope* scope); | 180 SourceDir GetCurrentGenDir(const Scope* scope); |
177 | 181 |
178 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ | 182 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ |
OLD | NEW |