diff options
author | Anne Jan Brouwer <brouwer@annejan.com> | 2016-12-16 01:38:58 +0100 |
---|---|---|
committer | Anne Jan Brouwer <brouwer@annejan.com> | 2016-12-16 01:38:58 +0100 |
commit | c89c36674a48f63ebb61743db1ce029ae9d91c71 (patch) | |
tree | 086caaa325550a209ba18dea87a3b8d8616519df /src/realpass.cpp | |
parent | 34afa71633ffc5d1222f64edfd9ed351f9da80da (diff) |
cleanup and autoupdates
Diffstat (limited to 'src/realpass.cpp')
-rw-r--r-- | src/realpass.cpp | 140 |
1 files changed, 76 insertions, 64 deletions
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<UserInfo> &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); +} |