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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 // | 109 // |
110 // The source_root should be a base::FilePath converted to UTF-8. On Windows, | 110 // The source_root should be a base::FilePath converted to UTF-8. On Windows, |
111 // it should begin with a "C:/" rather than being our SourceFile's style | 111 // it should begin with a "C:/" rather than being our SourceFile's style |
112 // ("/C:/"). The source root can end with a slash or not. | 112 // ("/C:/"). The source root can end with a slash or not. |
113 // | 113 // |
114 // Note that this does not attempt to normalize slashes in the output. | 114 // Note that this does not attempt to normalize slashes in the output. |
115 bool MakeAbsolutePathRelativeIfPossible(const base::StringPiece& source_root, | 115 bool MakeAbsolutePathRelativeIfPossible(const base::StringPiece& source_root, |
116 const base::StringPiece& path, | 116 const base::StringPiece& path, |
117 std::string* dest); | 117 std::string* dest); |
118 | 118 |
119 // Converts a directory to its inverse (e.g. "/foo/bar/" -> "../../"). | |
120 // This will be the empty string for the root directories ("/" and "//"), and | |
121 // in all other cases, this is guaranteed to end in a slash. | |
122 std::string InvertDir(const SourceDir& dir); | |
123 | |
124 // Collapses "." and sequential "/"s and evaluates "..". | 119 // Collapses "." and sequential "/"s and evaluates "..". |
125 void NormalizePath(std::string* path); | 120 void NormalizePath(std::string* path); |
126 | 121 |
127 // Converts slashes to backslashes for Windows. Keeps the string unchanged | 122 // Converts slashes to backslashes for Windows. Keeps the string unchanged |
128 // for other systems. | 123 // for other systems. |
129 void ConvertPathToSystem(std::string* path); | 124 void ConvertPathToSystem(std::string* path); |
130 | 125 |
131 // Takes a source-absolute path (must begin with "//") and makes it relative | 126 // Takes a path, |input|, and makes it relative to the given directory |
132 // to the given directory, which also must be source-absolute. | 127 // |dest_dir|. Both inputs may be source-relative (e.g. begins with |
133 std::string RebaseSourceAbsolutePath(const std::string& input, | 128 // with "//") or may be absolute. |
134 const SourceDir& dest_dir); | 129 // |
130 // If supplied, the |source_root| parameter must be the absolute path | |
brettw
2014/11/05 19:59:49
"must be" -> "is the". Can you explain here what h
zeuthen
2014/11/07 19:24:12
Done.
| |
131 // to the source root and not end in a slash. | |
132 std::string RebaseSourceAbsolutePath( | |
133 const std::string& input, | |
134 const SourceDir& dest_dir, | |
135 const base::StringPiece& source_root = base::StringPiece()); | |
135 | 136 |
136 // Returns the given directory with no terminating slash at the end, such that | 137 // Returns the given directory with no terminating slash at the end, such that |
137 // appending a slash and more stuff will produce a valid path. | 138 // appending a slash and more stuff will produce a valid path. |
138 // | 139 // |
139 // If the directory refers to either the source or system root, we'll append | 140 // If the directory refers to either the source or system root, we'll append |
140 // a "." so this remains valid. | 141 // a "." so this remains valid. |
141 std::string DirectoryWithNoLastSlash(const SourceDir& dir); | 142 std::string DirectoryWithNoLastSlash(const SourceDir& dir); |
142 | 143 |
143 // Returns the "best" SourceDir representing the given path. If it's inside the | 144 // Returns the "best" SourceDir representing the given path. If it's inside the |
144 // given source_root, a source-relative directory will be returned (e.g. | 145 // given source_root, a source-relative directory will be returned (e.g. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 | 183 |
183 SourceDir GetTargetOutputDir(const Target* target); | 184 SourceDir GetTargetOutputDir(const Target* target); |
184 OutputFile GetTargetOutputDirAsOutputFile(const Target* target); | 185 OutputFile GetTargetOutputDirAsOutputFile(const Target* target); |
185 SourceDir GetTargetGenDir(const Target* target); | 186 SourceDir GetTargetGenDir(const Target* target); |
186 OutputFile GetTargetGenDirAsOutputFile(const Target* target); | 187 OutputFile GetTargetGenDirAsOutputFile(const Target* target); |
187 | 188 |
188 SourceDir GetCurrentOutputDir(const Scope* scope); | 189 SourceDir GetCurrentOutputDir(const Scope* scope); |
189 SourceDir GetCurrentGenDir(const Scope* scope); | 190 SourceDir GetCurrentGenDir(const Scope* scope); |
190 | 191 |
191 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ | 192 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ |
OLD | NEW |