From c6fb7198d726d61d90a702aa66c89765c3f19e79 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 19 Oct 2018 13:10:18 +0200 Subject: shiboken: Use class FileOut for the module source file as well Ensure the diff/dry-run options work for this file as well. Move the touchFile() utility around and adapt the verifyDirectoryFor() helper to take a string. Task-number: PYSIDE-834 Change-Id: Ic34b5f8eff304d9de85f60082f582f0537805cd4 Reviewed-by: Alexandru Croitor Reviewed-by: Cristian Maureira-Fredes --- sources/shiboken2/ApiExtractor/fileout.cpp | 16 ++++++++++++++++ sources/shiboken2/ApiExtractor/fileout.h | 6 ++++++ 2 files changed, 22 insertions(+) (limited to 'sources/shiboken2/ApiExtractor') diff --git a/sources/shiboken2/ApiExtractor/fileout.cpp b/sources/shiboken2/ApiExtractor/fileout.cpp index 475eb386b..10a8f6be8 100644 --- a/sources/shiboken2/ApiExtractor/fileout.cpp +++ b/sources/shiboken2/ApiExtractor/fileout.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -231,3 +232,18 @@ FileOut::State FileOut::done(QString *errorMessage) return Success; } + +void FileOut::touchFile(const QString &filePath) +{ + QFile toucher(filePath); + qint64 size = toucher.size(); + if (!toucher.open(QIODevice::ReadWrite)) { + qCWarning(lcShiboken).noquote().nospace() + << QStringLiteral("Failed to touch file '%1'") + .arg(QDir::toNativeSeparators(filePath)); + return; + } + toucher.resize(size+1); + toucher.resize(size); + toucher.close(); +} diff --git a/sources/shiboken2/ApiExtractor/fileout.h b/sources/shiboken2/ApiExtractor/fileout.h index 6c27b5b00..aace70131 100644 --- a/sources/shiboken2/ApiExtractor/fileout.h +++ b/sources/shiboken2/ApiExtractor/fileout.h @@ -46,9 +46,15 @@ public: explicit FileOut(QString name); ~FileOut(); + QString filePath() const { return name; } + State done(); State done(QString *errorMessage); + void touch() { touchFile(name); } + + static void touchFile(const QString &filePath); + QTextStream stream; static bool dummy; -- cgit v1.2.3