Skip to content

Commit 8591817

Browse files
committed
Swift: ensure the folder for trap files exists
1 parent 9c73ae5 commit 8591817

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

swift/extractor/SwiftExtractor.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ static void extractFile(const SwiftExtractorConfiguration& config, swift::Source
5252
llvm::SmallString<PATH_MAX> tempTrapPath(config.trapDir);
5353
llvm::sys::path::append(tempTrapPath, tempTrapName);
5454

55+
llvm::StringRef trapParent = llvm::sys::path::parent_path(tempTrapPath);
56+
if (std::error_code ec = llvm::sys::fs::create_directories(trapParent)) {
57+
std::cerr << "Cannot create trap directory '" << trapParent.str() << "': " << ec.message()
58+
<< "\n";
59+
return;
60+
}
61+
5562
std::ofstream trap(tempTrapPath.str().str());
5663
if (!trap) {
5764
std::error_code ec;

0 commit comments

Comments
 (0)