| 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 |
| 128 // with "//") or may be absolute. The |source_root| parameter must be |
| 129 // the absolute path to the source root. |
| 133 std::string RebaseSourceAbsolutePath(const std::string& input, | 130 std::string RebaseSourceAbsolutePath(const std::string& input, |
| 134 const SourceDir& dest_dir); | 131 const SourceDir& dest_dir, |
| 132 const base::FilePath& source_root); |
| 135 | 133 |
| 136 // Returns the given directory with no terminating slash at the end, such that | 134 // 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. | 135 // appending a slash and more stuff will produce a valid path. |
| 138 // | 136 // |
| 139 // If the directory refers to either the source or system root, we'll append | 137 // If the directory refers to either the source or system root, we'll append |
| 140 // a "." so this remains valid. | 138 // a "." so this remains valid. |
| 141 std::string DirectoryWithNoLastSlash(const SourceDir& dir); | 139 std::string DirectoryWithNoLastSlash(const SourceDir& dir); |
| 142 | 140 |
| 143 // Returns the "best" SourceDir representing the given path. If it's inside the | 141 // 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. | 142 // 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 | 180 |
| 183 SourceDir GetTargetOutputDir(const Target* target); | 181 SourceDir GetTargetOutputDir(const Target* target); |
| 184 OutputFile GetTargetOutputDirAsOutputFile(const Target* target); | 182 OutputFile GetTargetOutputDirAsOutputFile(const Target* target); |
| 185 SourceDir GetTargetGenDir(const Target* target); | 183 SourceDir GetTargetGenDir(const Target* target); |
| 186 OutputFile GetTargetGenDirAsOutputFile(const Target* target); | 184 OutputFile GetTargetGenDirAsOutputFile(const Target* target); |
| 187 | 185 |
| 188 SourceDir GetCurrentOutputDir(const Scope* scope); | 186 SourceDir GetCurrentOutputDir(const Scope* scope); |
| 189 SourceDir GetCurrentGenDir(const Scope* scope); | 187 SourceDir GetCurrentGenDir(const Scope* scope); |
| 190 | 188 |
| 191 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ | 189 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ |
| OLD | NEW |