From c89c36674a48f63ebb61743db1ce029ae9d91c71 Mon Sep 17 00:00:00 2001 From: Anne Jan Brouwer Date: Fri, 16 Dec 2016 01:38:58 +0100 Subject: cleanup and autoupdates --- src/realpass.cpp | 140 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 64 deletions(-) (limited to 'src/realpass.cpp') diff --git a/src/realpass.cpp b/src/realpass.cpp index 2baec515..b360dd2f 100644 --- a/src/realpass.cpp +++ b/src/realpass.cpp @@ -3,7 +3,6 @@ RealPass::RealPass() {} - /** * @brief RealPass::GitInit pass git init wrapper */ @@ -91,70 +90,83 @@ void RealPass::Init(QString path, const QList &users) { } executePass(PASS_INIT, args); } -void RealPass::Move(const QString src, const QString dest, const bool force) -{ - QFileInfo srcFileInfo= QFileInfo(src); - QFileInfo destFileInfo= QFileInfo(dest); - - // force mode? - // pass uses always the force mode, when call from eg. QT. so we have to check if this are to files - // and the user didnt want to move force - if(force == false && srcFileInfo.isFile() && destFileInfo.isFile()){ - return; - } - - QString passSrc = QDir(QtPassSettings::getPassStore()).relativeFilePath(QDir(src).absolutePath()); - QString passDest= QDir(QtPassSettings::getPassStore()).relativeFilePath(QDir(dest).absolutePath()); - - - // remove the .gpg because pass will not work - if(srcFileInfo.isFile() && srcFileInfo.suffix() == "gpg"){ - passSrc.replace(QRegExp("\\.gpg$"), ""); - } - if(destFileInfo.isFile() && destFileInfo.suffix() == "gpg"){ - passDest.replace(QRegExp("\\.gpg$"), ""); - } - - QStringList args; - args << "mv"; - if(force){ - args << "-f"; - } - args << passSrc; - args << passDest; - executePass(PASS_MOVE, args); -} +/** + * @brief RealPass::Move move a file (or folder) + * @param src source file or folder + * @param dest destination file or folder + * @param force overwrite + */ +void RealPass::Move(const QString src, const QString dest, const bool force) { + QFileInfo srcFileInfo = QFileInfo(src); + QFileInfo destFileInfo = QFileInfo(dest); + + // force mode? + // pass uses always the force mode, when call from eg. QT. so we have to check + // if this are to files + // and the user didnt want to move force + if (force == false && srcFileInfo.isFile() && destFileInfo.isFile()) { + return; + } + + QString passSrc = QDir(QtPassSettings::getPassStore()) + .relativeFilePath(QDir(src).absolutePath()); + QString passDest = QDir(QtPassSettings::getPassStore()) + .relativeFilePath(QDir(dest).absolutePath()); -void RealPass::Copy(const QString src, const QString dest, const bool force) -{ - QFileInfo srcFileInfo= QFileInfo(src); - QFileInfo destFileInfo= QFileInfo(dest); - // force mode? - // pass uses always the force mode, when call from eg. QT. so we have to check if this are to files - // and the user didnt want to move force - if(force == false && srcFileInfo.isFile() && destFileInfo.isFile()){ - return; - } - - QString passSrc = QDir(QtPassSettings::getPassStore()).relativeFilePath(QDir(src).absolutePath()); - QString passDest= QDir(QtPassSettings::getPassStore()).relativeFilePath(QDir(dest).absolutePath()); - - - // remove the .gpg because pass will not work - if(srcFileInfo.isFile() && srcFileInfo.suffix() == "gpg"){ - passSrc.replace(QRegExp("\\.gpg$"), ""); - } - if(destFileInfo.isFile() && destFileInfo.suffix() == "gpg"){ - passDest.replace(QRegExp("\\.gpg$"), ""); - } - QStringList args; - args << "cp"; - if(force){ - args << "-f"; - } - args << passSrc; - args << passDest; - executePass(PASS_COPY, args); + // remove the .gpg because pass will not work + if (srcFileInfo.isFile() && srcFileInfo.suffix() == "gpg") { + passSrc.replace(QRegExp("\\.gpg$"), ""); + } + if (destFileInfo.isFile() && destFileInfo.suffix() == "gpg") { + passDest.replace(QRegExp("\\.gpg$"), ""); + } + + QStringList args; + args << "mv"; + if (force) { + args << "-f"; + } + args << passSrc; + args << passDest; + executePass(PASS_MOVE, args); } +/** + * @brief RealPass::Copy copy a file (or folder) + * @param src source file or folder + * @param dest destination file or folder + * @param force overwrite + */ +void RealPass::Copy(const QString src, const QString dest, const bool force) { + QFileInfo srcFileInfo = QFileInfo(src); + QFileInfo destFileInfo = QFileInfo(dest); + // force mode? + // pass uses always the force mode, when call from eg. QT. so we have to check + // if this are to files + // and the user didnt want to move force + if (force == false && srcFileInfo.isFile() && destFileInfo.isFile()) { + return; + } + + QString passSrc = QDir(QtPassSettings::getPassStore()) + .relativeFilePath(QDir(src).absolutePath()); + QString passDest = QDir(QtPassSettings::getPassStore()) + .relativeFilePath(QDir(dest).absolutePath()); + + // remove the .gpg because pass will not work + if (srcFileInfo.isFile() && srcFileInfo.suffix() == "gpg") { + passSrc.replace(QRegExp("\\.gpg$"), ""); + } + if (destFileInfo.isFile() && destFileInfo.suffix() == "gpg") { + passDest.replace(QRegExp("\\.gpg$"), ""); + } + QStringList args; + args << "cp"; + if (force) { + args << "-f"; + } + args << passSrc; + args << passDest; + executePass(PASS_COPY, args); +} -- cgit v1.2.3