Ejemplo n.º 1
0
bool DkBatchProcess::prepareDeleteExisting() {

    if (QFileInfo(mFilePathOut).exists() && mMode == DkBatchConfig::mode_overwrite) {

        // create unique back-up file name
        QFileInfo buFile(mFilePathOut);
        buFile = QFileInfo(buFile.absolutePath(), buFile.baseName() + QUuid::createUuid().toString() + "." + buFile.suffix());

        // check the uniqueness : )
        if (buFile.exists()) {
            mLogStrings.append(QObject::tr("Error: back-up (%1) file already exists").arg(buFile.absoluteFilePath()));
            return false;
        }

        QFile file(mFilePathOut);

        if (!file.rename(buFile.absoluteFilePath())) {
            mLogStrings.append(QObject::tr("Error: could not rename existing file to %1").arg(buFile.absoluteFilePath()));
            mLogStrings.append(file.errorString());
            return false;
        }
        else
            mBackupFilePath = buFile.absoluteFilePath();
    }

    return true;
}
Ejemplo n.º 2
0
void DkSaveInfo::createBackupFilePath() {

	QFileInfo buFile(mFilePathOut);
	mBackupPath = QFileInfo(buFile.absolutePath(), buFile.baseName() + QUuid::createUuid().toString() + "." + buFile.suffix()).absoluteFilePath();
}