本文整理汇总了C++中QDir::isReadable方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::isReadable方法的具体用法?C++ QDir::isReadable怎么用?C++ QDir::isReadable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDir
的用法示例。
在下文中一共展示了QDir::isReadable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ensureDirectoriesExist
bool Brewtarget::ensureDirectoriesExist()
{
bool success;
QDir dir;
QString errTitle(QObject::tr("Directory Problem"));
QString errText(QObject::tr("\"%1\" cannot be read."));
// Check data dir
dir.setPath(getDataDir());
if( ! dir.exists() || ! dir.isReadable() )
{
QMessageBox::information(
0,
errTitle,
errText.arg(dir.path())
);
return false;
}
// Check doc dir
dir.setPath(getDocDir());
if( ! dir.exists() || ! dir.isReadable() )
{
QMessageBox::information(
0,
errTitle,
errText.arg(dir.path())
);
return false;
}
// Check config dir
dir.setPath(getConfigDir(&success));
if( !success || ! dir.exists() || ! dir.isReadable() )
{
QMessageBox::information(
0,
errTitle,
errText.arg(dir.path())
);
return false;
}
// Check/create user data directory
dir.setPath(getUserDataDir());
if( !dir.exists() && !dir.mkpath(".") )
{
QMessageBox::information(
0,
errTitle,
errText.arg(dir.path())
);
return false;
}
return true;
}
示例2: load
void AudioPluginCache::load(const QDir &dir)
{
qDebug() << Q_FUNC_INFO << dir.path();
/* Check that we can access the directory */
if (dir.exists() == false || dir.isReadable() == false)
return;
/* Loop through all files in the directory */
QStringListIterator it(dir.entryList());
while (it.hasNext() == true)
{
/* Attempt to load a plugin from the path */
QString fileName(it.next());
QString path = dir.absoluteFilePath(fileName);
QPluginLoader loader(path, this);
AudioDecoder* ptr = qobject_cast<AudioDecoder*> (loader.instance());
if (ptr != NULL)
{
qDebug() << "Loaded audio decoder plugin from" << fileName;
/* Just append the plugin path to be used at runtime
* for dynamic creation of instances */
ptr->initialize("");
m_pluginsPathList << path;
loader.unload();
}
else
qDebug() << "Failed to load plugin: " << loader.errorString();
}
}
示例3: QDir
QDir
Configuration::getStorageLocation(const StorageLocation &type) const
{
QDir location;
switch (type)
{
case FaviconStorageLocation:
location = QDir(QStandardPaths::writableLocation(
QStandardPaths::CacheLocation));
break;
case SystemExtensionsLocation:
location = QDir(PlatformDependent::p()->extensionsDir(
PlatformDependent::System));
break;
case UserExtensionsLocation:
location = QDir(PlatformDependent::p()->extensionsDir(
PlatformDependent::User));
break;
case SystemPresetsLocation:
location = QDir(PlatformDependent::p()->presetsDir(
PlatformDependent::System));
break;
case UserPresetsLocation:
location = QDir(PlatformDependent::p()->presetsDir(
PlatformDependent::User));
break;
default:
return QDir();
}
if (! location.isReadable() )
return QDir();
return location;
}
示例4: copyDir
bool Config::copyDir(QDir src, QDir dest) const {
if(!src.isReadable())
return false;
QFileInfoList entries = src.entryInfoList();
QList<QFileInfo>::iterator it;
for(it=entries.begin(); it!=entries.end(); it++) {
QFileInfo &finfo = *it;
if(finfo.fileName()=="." || finfo.fileName()=="..") {
// Nada
} else if(finfo.isDir()) {
dest.mkdir(finfo.fileName());
src.cd(finfo.fileName());
dest.cd(finfo.fileName());
this->copyDir(src, dest);
src.cdUp();
dest.cdUp();
} else if(finfo.isFile()) {
QFile file(finfo.filePath());
file.copy(dest.absoluteFilePath(finfo.fileName()));
}
}
return true;
}
示例5: loadMidiTemplates
void MidiPlugin::loadMidiTemplates(const QDir& dir)
{
qDebug() << "loadMidiTemplates from " << dir.absolutePath();
if (dir.exists() == false || dir.isReadable() == false)
return;
/* Go thru all found file entries and attempt to load a midi
template from each of them. */
QStringListIterator it(dir.entryList());
while (it.hasNext() == true)
{
QString path = dir.absoluteFilePath(it.next());
qDebug() << "file: " << path;
MidiTemplate* templ;
templ = MidiTemplate::loader(path);
if (templ != NULL)
{
addMidiTemplate(templ);
} else
{
qWarning() << Q_FUNC_INFO << "Unable to load a midi template from" << path;
}
}
}
示例6: loadProfiles
void InputMap::loadProfiles(const QDir& dir)
{
if (dir.exists() == false || dir.isReadable() == false)
return;
/* Go thru all found file entries and attempt to load an input
profile from each of them. */
QStringListIterator it(dir.entryList());
while (it.hasNext() == true)
{
QLCInputProfile* prof;
QString path;
path = dir.absoluteFilePath(it.next());
prof = QLCInputProfile::loader(path);
if (prof != NULL)
{
/* Check for duplicates */
if (profile(prof->name()) == NULL)
addProfile(prof);
else
delete prof;
}
else
{
qWarning() << Q_FUNC_INFO << "Unable to find an input profile from" << path;
}
}
}
示例7: checkExistingReadableDir
void FileManager::checkExistingReadableDir(QDir dir) {
if (!dir.isReadable()) {
QLOG_FATAL() << "Directory '" + dir.path() + "' does not have read permission. Aborting program.";
exit(16);
}
if (!dir.exists()) {
QLOG_FATAL() << "Directory '" + dir.path() + "' does not exist. Aborting program";
exit(16);
}
}
示例8: readDir
void QtFileIconView::readDir( const QDir &dir )
{
if ( !dir.isReadable() )
return;
if ( isRoot( dir.absPath() ) )
emit disableUp();
else
emit enableUp();
clear();
emit directoryChanged( dir.absPath() );
const QFileInfoList *filist = dir.entryInfoList( QDir::DefaultFilter, QDir::DirsFirst | QDir::Name );
emit startReadDir( filist->count() );
QFileInfoListIterator it( *filist );
QFileInfo *fi;
bool allowRename = FALSE, allowRenameSet = FALSE;
while ( ( fi = it.current() ) != 0 ) {
++it;
if ( fi && fi->fileName() == ".." && ( fi->dirPath() == "/" || fi->dirPath().isEmpty() ) )
continue;
emit readNextDir();
QtFileIconViewItem *item = new QtFileIconViewItem( this, new QFileInfo( *fi ) );
if ( fi->isDir() )
item->setKey( QString( "000000%1" ).arg( fi->fileName() ) );
else
item->setKey( fi->fileName() );
if ( !allowRenameSet ) {
if ( !QFileInfo( fi->absFilePath() ).isWritable() ||
item->text() == "." || item->text() == ".." )
allowRename = FALSE;
else
allowRename = TRUE;
if ( item->text() == "." || item->text() == ".." )
allowRenameSet = FALSE;
else
allowRenameSet = TRUE;
}
item->setRenameEnabled( allowRename );
}
if ( !QFileInfo( dir.absPath() ).isWritable() )
emit disableMkdir();
else
emit enableMkdir();
emit readDirDone();
}
示例9: load
void IOPluginCache::load(const QDir& dir)
{
qDebug() << Q_FUNC_INFO << dir.path();
/* Check that we can access the directory */
if (dir.exists() == false || dir.isReadable() == false)
return;
/* Loop thru all files in the directory */
QStringListIterator it(dir.entryList());
while (it.hasNext() == true)
{
/* Attempt to load a plugin from the path */
QString fileName(it.next());
QString path = dir.absoluteFilePath(fileName);
QPluginLoader loader(path, this);
QLCIOPlugin* ptr = qobject_cast<QLCIOPlugin*> (loader.instance());
if (ptr != NULL)
{
/* Check for duplicates */
if (plugin(ptr->name()) == NULL)
{
/* New plugin. Append and init. */
qDebug() << "Loaded I/O plugin" << ptr->name() << "from" << fileName;
emit pluginLoaded(ptr->name());
ptr->init();
m_plugins << ptr;
connect(ptr, SIGNAL(configurationChanged()),
this, SLOT(slotConfigurationChanged()));
#if !defined(Q_OS_ANDROID)
HotPlugMonitor::connectListener(ptr);
#endif
// QLCi18n::loadTranslation(p->name().replace(" ", "_"));
}
else
{
/* Duplicate plugin. Unload it. */
qWarning() << Q_FUNC_INFO << "Discarded duplicate I/O plugin"
<< ptr->name() << "in" << path;
loader.unload();
}
}
else
{
qWarning() << Q_FUNC_INFO << fileName << "doesn't contain an I/O plugin:"
<< loader.errorString();
loader.unload();
}
}
}
示例10: createDirOrCheckWriteable
void FileManager::createDirOrCheckWriteable(QDir dir) {
if (!dir.exists()) {
if (!dir.mkdir(dir.path())) {
QLOG_FATAL() << "Failed to create directory '" << dir.path() << "'. Aborting program.";
exit(16);
}
} else {
if (!dir.isReadable()) {
QLOG_FATAL() << "Directory '" + dir.path() + "' does not have read permission. Aborting program.";
exit(16);
}
}
}
示例11: slotAddClicked
void BtInstallPathDialog::slotAddClicked() {
QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (dirname.isEmpty()) { // if user cancelled the dialog
return;
}
QDir dir = QDir(dirname);
if (dir.isReadable()) {
const QFileInfo fi( dir.canonicalPath() );
if (!fi.exists() || !fi.isWritable()) {
const int result = message::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you still want to add it to the list of bookshelf folders?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (result != QMessageBox::Yes) {
return;
}
}
addPathToList(util::directory::convertDirSeparators(dir.canonicalPath()));
updateTopLevelItems();
}
}
示例12: GetTorrentSettings
bool KTorrentImportPage::GetTorrentSettings (const QString& path,
QMap<QString, QVariant>& settings) const
{
QDir torrentDir (path);
if (!torrentDir.exists () ||
!torrentDir.isReadable())
return false;
QFileInfoList files = torrentDir
.entryInfoList (QDir::Files | QDir::Readable, QDir::Unsorted);
for (int i = 0; i < files.size (); ++i)
{
QFile file (files.at (i).fileName ());
settings.insert (files.at (i).fileName (), file.readAll ());
}
return true;
}
示例13: loadPlugins
void OutputMap::loadPlugins(const QDir& dir)
{
/* Check that we can access the directory */
if (dir.exists() == false || dir.isReadable() == false)
return;
/* Loop thru all files in the directory */
QStringListIterator it(dir.entryList());
while (it.hasNext() == true)
{
/* Attempt to load a plugin from the path */
QString fileName(it.next());
QString path = dir.absoluteFilePath(fileName);
QPluginLoader loader(path, this);
QLCOutPlugin* p = qobject_cast<QLCOutPlugin*> (loader.instance());
if (p != NULL)
{
/* Check for duplicates */
if (plugin(p->name()) == NULL)
{
/* New plugin. Append and init. */
qDebug() << "Output plugin" << p->name() << "from" << fileName;
p->init();
appendPlugin(p);
QLCi18n::loadTranslation(p->name().replace(" ", "_"));
}
else
{
/* Duplicate plugin. Unload it. */
qWarning() << Q_FUNC_INFO << "Discarded duplicate output plugin"
<< path;
loader.unload();
}
}
else
{
qWarning() << Q_FUNC_INFO << fileName
<< "doesn't contain a QLC output plugin:"
<< loader.errorString();
loader.unload();
}
}
}
示例14: dir
QStringList * zEmotIcons::getSmilePackList()
{
QStringList * list = new QStringList();
QDir dir ( ProgDir+"smile/", "", QDir::Name | QDir::DirsFirst | QDir::IgnoreCase );
#ifdef OLD_SDK
dir.setMatchAllDirs ( true );
#endif
dir.setFilter ( QDir::Dirs );
if ( !dir.isReadable() )
return list;
QStringList entries = dir.entryList();
for ( QStringList::ConstIterator it = entries.begin(); it != entries.end(); it++ )
if ( (*it)[0] != "." )
list->append(*it);
return list;
}
示例15: run
void ImageOpenThread::run()
{
if (FUrl.scheme()=="file")
{
int dot=FUrl.path().lastIndexOf('.');
if (dot>0)
{
QString ext=FUrl.path().mid(dot+1);
if (!ext.isEmpty())
{
QStringList validExtensions;
validExtensions << "png" << "gif" << "jpg" << "jpeg" << "ico" << "bmp" << "tif" << "tiff" << "svg";
if (validExtensions.contains(ext, Qt::CaseInsensitive))
{
QDesktopServices::openUrl(FUrl.path());
return;
}
}
}
QDir temp = QDir::temp();
if (temp.isReadable())
{
QString fileName=FUrl.toLocalFile();
QImageReader reader(fileName);
if (reader.canRead())
{
QString type(reader.format());
QString tmpFileName(fileName);
tmpFileName.append('.').append(type);
QFile tmpFile(temp.filePath(tmpFileName));
if (!tmpFile.exists() || tmpFile.size()!=reader.device()->size()) // Exists already
QFile::copy(fileName, tmpFileName);
QDesktopServices::openUrl(QUrl::fromLocalFile(tmpFile.fileName()));
}
else
LOG_WARNING("Reader can't' read!");
}
}
else
QDesktopServices::openUrl(FUrl);
}