diff options
author | Topi Reinio <topi.reinio@qt.io> | 2020-10-05 17:58:48 +0200 |
---|---|---|
committer | Topi Reinio <topi.reinio@qt.io> | 2020-10-10 13:53:16 +0200 |
commit | 9d1dd394191001cf2bc456cf73e702eeb7bac400 (patch) | |
tree | 6b43c4ece47045009dcf58e7f972ae241b9edd79 /src/qdoc/generator.cpp | |
parent | 07e5b38a61871dbbb76af4000b59fc9e7f4e44cc (diff) | |
download | qttools-9d1dd394191001cf2bc456cf73e702eeb7bac400.tar.gz |
qdoc: Stop removing content of the output directory
QDoc deleted the contents of the directory specified by -outputdir in
prepare phase - this was dangerous for users that do not expect that
behavior.
Instead of deleting, print out an error if the output directory is not
empty.
Fixes: QTBUG-87176
Change-Id: Iabefcc9733cf4c4b875fdd2bfd7f86f79d25349c
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/qdoc/generator.cpp')
-rw-r--r-- | src/qdoc/generator.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/qdoc/generator.cpp b/src/qdoc/generator.cpp index 8b7fc9cb0..cea19c996 100644 --- a/src/qdoc/generator.cpp +++ b/src/qdoc/generator.cpp @@ -1851,14 +1851,14 @@ void Generator::initializeFormat() outSubdir_ = outDir_.mid(outDir_.lastIndexOf('/') + 1); } - QDir dirInfo; - if (dirInfo.exists(outDir_)) { + QDir outputDir(outDir_); + if (outputDir.exists()) { if (!config.generating() && Generator::useOutputSubdirs()) { - if (!Config::removeDirContents(outDir_)) + if (!outputDir.isEmpty()) config.lastLocation().error( - QStringLiteral("Cannot empty output directory '%1'").arg(outDir_)); + QStringLiteral("Output directory '%1' exists but is not empty").arg(outDir_)); } - } else if (!dirInfo.mkpath(outDir_)) { + } else if (!outputDir.mkpath(QStringLiteral("."))) { config.lastLocation().fatal( QStringLiteral("Cannot create output directory '%1'").arg(outDir_)); } @@ -1867,9 +1867,10 @@ void Generator::initializeFormat() if (config.preparing()) return; - if (!dirInfo.exists(outDir_ + "/images") && !dirInfo.mkdir(outDir_ + "/images")) + const QLatin1String imagesDir("images"); + if (!outputDir.exists(imagesDir) && !outputDir.mkdir(imagesDir)) config.lastLocation().fatal( - QStringLiteral("Cannot create images directory '%1'").arg(outDir_ + "/images")); + QStringLiteral("Cannot create images directory '%1'").arg(outputDir.filePath(imagesDir))); copyTemplateFiles(format() + Config::dot + CONFIG_STYLESHEETS, "style"); copyTemplateFiles(format() + Config::dot + CONFIG_SCRIPTS, "scripts"); |