本文整理汇总了C++中FileName::extension方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::extension方法的具体用法?C++ FileName::extension怎么用?C++ FileName::extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::extension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addExtension
FileName FileName::addExtension(const QString &newExtension) const {
FileName result = *this;
if (result.extension() != newExtension) {
QString attributesStr = result.attributes();
if (attributesStr == "")
result = FileName(result.originalPath() + "/" + result.name() + "." + newExtension);
else
result = FileName(result.originalPath() + "/" + result.name() + "." + newExtension
+ "+" + attributesStr);
}
return result;
}
示例2: createTempFile
FileName FileName::createTempFile(FileName templateFileName) {
QString preppedFileName = QString("%1/%2XXXXXX.%3").arg(templateFileName.path())
.arg(templateFileName.baseName()).arg(templateFileName.extension());
QTemporaryFile tempFile(preppedFileName);
tempFile.setAutoRemove(false);
if (!tempFile.open()) {
throw IException(IException::Io,
QObject::tr("Could not create a unique temporary file name based on [%1]")
.arg(templateFileName.original()),
_FILEINFO_);
}
// We want to set the 'original' path as correctly as possible. So let's use the input original
// path with the output temp file's file name in our result.
FileName result;
QString newTempFileNameStr = templateFileName.originalPath() + "/" +
QFileInfo(tempFile.fileName()).fileName();
result = FileName(newTempFileNameStr);
return result;
}