FileName FileName::highestVersion() const { validateVersioningState(); FileName result = *this; if (!isVersioned()) { throw IException(IException::Unknown, QObject::tr("Asked for highest version of file named [%1] in [%2] but there " "are no version sequences in the name") .arg(name()).arg(originalPath()), _FILEINFO_); } // Look for dates if (isDateVersioned()) { result = result.version(result.highestVersionDate()); } // Look for number's if (isNumericallyVersioned()) { result = result.version(result.highestVersionNum()); } return result; }
FileName FileName::newVersion() const { validateVersioningState(); FileName result = *this; if (!isVersioned()) { throw IException(IException::Unknown, QObject::tr("Asked for new version of file named [%1] in [%2] but there " "are no version sequences in the name") .arg(name()).arg(originalPath()), _FILEINFO_); } // Look for date if (isDateVersioned()) { result = result.version(QDate::currentDate()); } // Look for #'s if (isNumericallyVersioned()) { try { result = result.version(result.highestVersionNum() + 1); } catch (IException &) { result = result.version(1); } } if (result.fileExists()) { throw IException(IException::Unknown, QObject::tr("Could not generate unique new version of file named [%1] in " "[%2] because the file [%3] exists") .arg(name()).arg(originalPath()).arg(result.name()), _FILEINFO_); } return result; }