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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // | 104 // |
105 // The source_root should be a base::FilePath converted to UTF-8. On Windows, | 105 // The source_root should be a base::FilePath converted to UTF-8. On Windows, |
106 // it should begin with a "C:/" rather than being our SourceFile's style | 106 // it should begin with a "C:/" rather than being our SourceFile's style |
107 // ("/C:/"). The source root can end with a slash or not. | 107 // ("/C:/"). The source root can end with a slash or not. |
108 // | 108 // |
109 // Note that this does not attempt to normalize slashes in the output. | 109 // Note that this does not attempt to normalize slashes in the output. |
110 bool MakeAbsolutePathRelativeIfPossible(const base::StringPiece& source_root, | 110 bool MakeAbsolutePathRelativeIfPossible(const base::StringPiece& source_root, |
111 const base::StringPiece& path, | 111 const base::StringPiece& path, |
112 std::string* dest); | 112 std::string* dest); |
113 | 113 |
114 // Collapses "." and sequential "/"s and evaluates "..". | 114 // Collapses "." and sequential "/"s and evaluates "..". |path| may be |
115 void NormalizePath(std::string* path); | 115 // system-absolute, source-absolute, or relative. If |path| is source-absolute |
| 116 // and |source_root| is non-empty, |path| may be system absolute after this |
| 117 // function returns, if |path| references the filesystem outside of |
| 118 // |source_root| (ex. path = "//.."). Otherwise, |path| will retain its |
| 119 // relativity. |
| 120 void NormalizePath(std::string* path, |
| 121 const base::StringPiece& source_root = base::StringPiece()); |
116 | 122 |
117 // Converts slashes to backslashes for Windows. Keeps the string unchanged | 123 // Converts slashes to backslashes for Windows. Keeps the string unchanged |
118 // for other systems. | 124 // for other systems. |
119 void ConvertPathToSystem(std::string* path); | 125 void ConvertPathToSystem(std::string* path); |
120 | 126 |
121 // Takes a path, |input|, and makes it relative to the given directory | 127 // Takes a path, |input|, and makes it relative to the given directory |
122 // |dest_dir|. Both inputs may be source-relative (e.g. begins with | 128 // |dest_dir|. Both inputs may be source-relative (e.g. begins with |
123 // with "//") or may be absolute. | 129 // with "//") or may be absolute. |
124 // | 130 // |
125 // If supplied, the |source_root| parameter is the absolute path to | 131 // If supplied, the |source_root| parameter is the absolute path to |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 194 |
189 SourceDir GetTargetOutputDir(const Target* target); | 195 SourceDir GetTargetOutputDir(const Target* target); |
190 OutputFile GetTargetOutputDirAsOutputFile(const Target* target); | 196 OutputFile GetTargetOutputDirAsOutputFile(const Target* target); |
191 SourceDir GetTargetGenDir(const Target* target); | 197 SourceDir GetTargetGenDir(const Target* target); |
192 OutputFile GetTargetGenDirAsOutputFile(const Target* target); | 198 OutputFile GetTargetGenDirAsOutputFile(const Target* target); |
193 | 199 |
194 SourceDir GetCurrentOutputDir(const Scope* scope); | 200 SourceDir GetCurrentOutputDir(const Scope* scope); |
195 SourceDir GetCurrentGenDir(const Scope* scope); | 201 SourceDir GetCurrentGenDir(const Scope* scope); |
196 | 202 |
197 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ | 203 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ |
OLD | NEW |