| Index: tools/gn/filesystem_utils.cc
|
| diff --git a/tools/gn/filesystem_utils.cc b/tools/gn/filesystem_utils.cc
|
| index 663e6ac3f0c188d708a366d3326eb273605d4130..1f8fe81d2cf2668c10a2de2155f50351a4c18c00 100644
|
| --- a/tools/gn/filesystem_utils.cc
|
| +++ b/tools/gn/filesystem_utils.cc
|
| @@ -332,6 +332,32 @@ bool EnsureStringIsInOutputDir(const SourceDir& output_dir,
|
| return false;
|
| }
|
|
|
| +base::FilePath::StringType ComputeStringInOutputDir(const SourceDir& output_dir,
|
| + const SourceFile& output_file,
|
| + Err* err) {
|
| + if (output_file.is_source_absolute() != output_dir.is_source_absolute()) {
|
| + *err = Err(nullptr,
|
| + "Cannot determine if output file is in output directory",
|
| + "Absolute files/dirs are incomparable with source rooted ones.");
|
| + return base::FilePath::StringType();
|
| + }
|
| +
|
| + const std::string& dir_str = output_dir.value();
|
| + const std::string& str = output_file.value();
|
| + if (str.compare(0, dir_str.length(), dir_str) != 0 ||
|
| + str.length() <= dir_str.length() ||
|
| + IsSlash(str[dir_str.length()])) {
|
| + *err = Err(nullptr, "File is not inside output directory.",
|
| + "The given file should be in the output directory. Normally you would "
|
| + "specify\n\"$target_out_dir/foo\" or "
|
| + "\"$target_gen_dir/foo\". I interpreted this as\n\""
|
| + + str + "\".");
|
| + return base::FilePath::StringType();
|
| + }
|
| + return base::FilePath::StringType(str.c_str() + dir_str.length(),
|
| + str.length() - dir_str.length());
|
| +}
|
| +
|
| bool IsPathAbsolute(const base::StringPiece& path) {
|
| if (path.empty())
|
| return false;
|
|
|