本文整理汇总了C++中QFileSystemEntry::isAbsolute方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileSystemEntry::isAbsolute方法的具体用法?C++ QFileSystemEntry::isAbsolute怎么用?C++ QFileSystemEntry::isAbsolute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileSystemEntry
的用法示例。
在下文中一共展示了QFileSystemEntry::isAbsolute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defaultCtor
void tst_QFileSystemEntry::defaultCtor()
{
QFileSystemEntry entry;
QVERIFY(entry.filePath().isNull());
QVERIFY(entry.nativeFilePath().isNull());
QVERIFY(entry.fileName().isNull());
QCOMPARE(entry.path(), QString("."));
QVERIFY(entry.baseName().isNull());
QVERIFY(entry.completeBaseName().isNull());
QVERIFY(entry.suffix().isNull());
QVERIFY(entry.completeSuffix().isNull());
QVERIFY(!entry.isAbsolute());
QVERIFY(entry.isRelative());
QVERIFY(entry.isClean());
#if defined(Q_OS_WIN)
QVERIFY(!entry.isDriveRoot());
#endif
QVERIFY(!entry.isRoot());
QVERIFY(entry.isEmpty());
}
示例2: absoluteName
//static
QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
{
if (entry.isAbsolute() && entry.isClean())
return entry;
QByteArray orig = entry.nativeFilePath();
QByteArray result;
if (orig.isEmpty() || !orig.startsWith('/')) {
QFileSystemEntry cur(currentPath());
result = cur.nativeFilePath();
}
if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) {
if (!result.isEmpty() && !result.endsWith('/'))
result.append('/');
result.append(orig);
}
if (result.length() == 1 && result[0] == '/')
return QFileSystemEntry(result, QFileSystemEntry::FromNativePath());
const bool isDir = result.endsWith('/');
/* as long as QDir::cleanPath() operates on a QString we have to convert to a string here.
* ideally we never convert to a string since that loses information. Please fix after
* we get a QByteArray version of QDir::cleanPath()
*/
QFileSystemEntry resultingEntry(result, QFileSystemEntry::FromNativePath());
QString stringVersion = QDir::cleanPath(resultingEntry.filePath());
if (isDir)
stringVersion.append(QLatin1Char('/'));
return QFileSystemEntry(stringVersion);
}
示例3: absoluteName
//static
QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
{
QString orig = entry.filePath();
const bool isAbsolute = entry.isAbsolute();
const bool isDirty = !entry.isClean();
if (isAbsolute && !isDirty)
return entry;
const bool isRelative = entry.isRelative();
const bool needsDrive = (!orig.isEmpty() && orig.at(0).unicode() == '/');
const bool isDriveLetter = !needsDrive && !isAbsolute && !isRelative && orig.length() == 2;
const bool isDriveRelative = !needsDrive && !isAbsolute && !isRelative && orig.length() > 2;
QString result;
if (needsDrive || isDriveLetter || isDriveRelative || !isAbsolute || orig.isEmpty()) {
QFileSystemEntry cur(currentPath());
if(needsDrive)
result = cur.filePath().left(2);
else if(isDriveRelative && cur.filePath().at(0) != orig.at(0))
result = orig.left(2); // for BC, see tst_QFileInfo::absolutePath(<not current drive>:my.dll)
else
result = cur.filePath();
if(isDriveLetter) {
result[0] = orig.at(0); //copy drive letter
orig.clear();
}
if(isDriveRelative) {
orig = orig.mid(2); //discard the drive specifier from orig
}
}
if (!orig.isEmpty() && !(orig.length() == 1 && orig.at(0).unicode() == '.')) {
if (!result.isEmpty() && !result.endsWith(QLatin1Char('/')))
result.append(QLatin1Char('/'));
result.append(orig);
}
return QFileSystemEntry(symbianCleanAbsolutePath(result), QFileSystemEntry::FromInternalPath());
}