Skip to content

Commit

Permalink
Merge pull request #432 from immunant/kkysen/make-directory-args-abso…
Browse files Browse the repository at this point in the history
…lute

rewriter: immediately make directory CLI args absolute
  • Loading branch information
kkysen authored Oct 8, 2024
2 parents 5391218 + ea351cc commit 698929c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tools/rewriter/SourceRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,19 @@ struct DirectoryParser : public llvm::cl::parser<std::string> {
bool parse(llvm::cl::Option &O, llvm::StringRef ArgName, const llvm::StringRef &ArgValue,
std::string &Value) {
llvm::cl::parser<std::string>::parse(O, ArgName, ArgValue, Value);
auto dir = Value;
auto exists = llvm::sys::fs::is_directory(dir);
llvm::SmallString<PATH_MAX> dir { llvm::StringRef(Value) };
bool exists = llvm::sys::fs::is_directory(dir);
if (!exists) {
llvm::errs() << "error: directory does not exist: " << dir << "\n";
return true; // true on error
}
// true on error
return !exists;
auto ec = llvm::sys::fs::make_absolute(dir);
if (ec) {
llvm::errs() << ec.message() << '\n';
return true;
}
Value = std::string(dir);
return false;
}
};

Expand Down

0 comments on commit 698929c

Please sign in to comment.