本文整理汇总了C++中QSystemError类的典型用法代码示例。如果您正苦于以下问题:C++ QSystemError类的具体用法?C++ QSystemError怎么用?C++ QSystemError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSystemError类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tfn
void QTemporaryDirPrivate::create(const QString &templateName)
{
QTemporaryFileName tfn(templateName);
for (int i = 0; i < 256; ++i) {
tfn.generateNext();
QFileSystemEntry fileSystemEntry(tfn.path, QFileSystemEntry::FromNativePath());
if (QFileSystemEngine::createDirectory(fileSystemEntry, false)) {
QSystemError error;
QFileSystemEngine::setPermissions(fileSystemEntry,
QFile::ReadOwner |
QFile::WriteOwner |
QFile::ExeOwner, error);
if (error.error() != 0) {
if (!QFileSystemEngine::removeDirectory(fileSystemEntry, false))
qWarning() << "Unable to remove unused directory" << templateName;
continue;
}
success = true;
pathOrError = fileSystemEntry.filePath();
return;
}
# ifdef Q_OS_WIN
const int exists = ERROR_ALREADY_EXISTS;
int code = GetLastError();
# else
const int exists = EEXIST;
int code = errno;
# endif
if (code != exists)
break;
}
pathOrError = qt_error_string();
success = false;
}
示例2: Q_D
bool QFSFileEngine::setPermissions(uint perms)
{
Q_D(QFSFileEngine);
QSystemError error;
bool ret = QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error);
if (!ret)
setError(QFile::PermissionsError, error.toString());
return ret;
}
示例3: Q_D
bool QFSFileEngine::setPermissions(uint perms)
{
Q_D(QFSFileEngine);
QSystemError error;
if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0)) {
setError(QFile::PermissionsError, error.toString());
return false;
}
return true;
}
示例4: Q_D
bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
{
Q_D(QFSFileEngine);
Q_ASSERT(!isReallyOpen());
openMode |= QIODevice::ReadWrite;
if (!filePathIsTemplate)
return QFSFileEngine::open(openMode);
QString qfilename = d->fileEntry.filePath();
// Ensure there is a placeholder mask
uint phPos = qfilename.length();
uint phLength = 0;
while (phPos != 0) {
--phPos;
if (qfilename[phPos] == QLatin1Char('X')) {
++phLength;
continue;
}
if (phLength >= 6
|| qfilename[phPos] == QLatin1Char('/')) {
++phPos;
break;
}
// start over
phLength = 0;
}
if (phLength < 6)
qfilename.append(QLatin1String(".XXXXXX"));
// "Nativify" :-)
QFileSystemEntry::NativePath filename = QFileSystemEngine::absoluteName(
QFileSystemEntry(qfilename, QFileSystemEntry::FromInternalPath()))
.nativeFilePath();
// Find mask in native path
phPos = filename.length();
phLength = 0;
while (phPos != 0) {
--phPos;
if (filename[phPos] == Latin1Char('X')) {
++phLength;
continue;
}
if (phLength >= 6) {
++phPos;
break;
}
// start over
phLength = 0;
}
Q_ASSERT(phLength >= 6);
QSystemError error;
#if defined(Q_OS_WIN)
NativeFileHandle &file = d->fileHandle;
#else // POSIX
NativeFileHandle &file = d->fd;
#endif
if (!createFileFromTemplate(file, filename, phPos, phLength, error)) {
setError(QFile::OpenError, error.toString());
return false;
}
d->fileEntry = QFileSystemEntry(filename, QFileSystemEntry::FromNativePath());
#if !defined(Q_OS_WIN) || defined(Q_OS_WINRT)
d->closeFileHandle = true;
#endif
filePathIsTemplate = false;
d->openMode = openMode;
d->lastFlushFailed = false;
d->tried_stat = 0;
return true;
}