当前位置: 首页>>代码示例>>C++>>正文


C++ QFileInfo::isReadable方法代码示例

本文整理汇总了C++中QFileInfo::isReadable方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfo::isReadable方法的具体用法?C++ QFileInfo::isReadable怎么用?C++ QFileInfo::isReadable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QFileInfo的用法示例。


在下文中一共展示了QFileInfo::isReadable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: excludeFile

QString ConfigFile::excludeFile(Scope scope) const
{
    // prefer sync-exclude.lst, but if it does not exist, check for
    // exclude.lst for compatibility reasons in the user writeable
    // directories.
    QFileInfo fi;

    switch (scope) {
    case UserScope:
        fi.setFile(configPath(), exclFile);

        if (!fi.isReadable()) {
            fi.setFile(configPath(), QLatin1String("exclude.lst"));
        }
        if (!fi.isReadable()) {
            fi.setFile(configPath(), exclFile);
        }
        return fi.absoluteFilePath();
    case SystemScope:
        return ConfigFile::excludeFileFromSystem();
    }

    ASSERT(false);
    return QString();
}
开发者ID:msphn,项目名称:client,代码行数:25,代码来源:configfile.cpp

示例2: hasChanged

// Check whether the file has changed on disk
// by looking at the time stamp
bool GLEFileInfo::hasChanged()
{
	QFileInfo fi;
	QString mainFile(primaryFile());
	if (mainFile.isEmpty())	{
		return false;
	}
	fi.setFile(mainFile);
	if (!fi.isReadable()) {
		return false;
	}
	QDateTime modifiedTime(fi.lastModified());
	if (modifiedTime > lastModified) {
		return true;
	} else {
		for (int i = 0; i < filesToMonitor.size(); ++i) {
			GLEFileData data(filesToMonitor.at(i));
			fi.setFile(data.fname);
			if (fi.isReadable() && fi.lastModified() > data.lastModified) {
				return true;
			}
		}
		return false;
	}
}
开发者ID:pnkfelix,项目名称:glx-gle,代码行数:27,代码来源:fileinfo.cpp

示例3: copyDirectory

  QMap< QString, QString> ConfigBase::exportDatas( const QString &directory ) {

    QDir copyDirectory( directory );

    QFileInfo fi;
    const QFileInfoList fil = copyDirectory.entryInfoList( QDir::Dirs | QDir::Files , QDir::Name );
    QListIterator< QFileInfo > it( fil );
    QMap< QString, QString> zipData;

    while ( it.hasNext() ) {
      fi = it.next();

      if ( fi.fileName() == "." || fi.fileName() == ".." ) {
        ;
      } else {
        if ( fi.isDir() && fi.isReadable() ) {
          exportDatas( fi.absoluteFilePath() );

        } else if ( fi.isFile() && fi.isReadable() ) {
          zipData.insert( fi.absolutePath(), fi.fileName() );
        }
      }
    }

    return zipData;
  }
开发者ID:BackupTheBerlios,项目名称:dboxfe-svn,代码行数:26,代码来源:base.cpp

示例4: initializePage

			void ThirdStep::initializePage ()
			{
				TotalSize_ = 0;
				QString path = field ("RootPath").toString ();

				QFileInfo pathInfo (path);
				if (pathInfo.isDir ())
				{
					QDirIterator it (path,
							QDirIterator::Subdirectories);
					while (it.hasNext ())
					{
						it.next ();
						QFileInfo info = it.fileInfo ();
						if (info.isFile () && info.isReadable ())
							TotalSize_ += info.size ();
					}
				}
				else if (pathInfo.isFile () &&
						pathInfo.isReadable ())
					TotalSize_ += pathInfo.size ();

				quint64 max = std::log (static_cast<long double> (TotalSize_ / 102400)) * 80;

				quint32 pieceSize = 32 * 1024;
				int shouldIndex = 0;
				for (; TotalSize_ / pieceSize >= max; pieceSize *= 2, ++shouldIndex) ;

				if (shouldIndex > PieceSize_->count () - 1)
					shouldIndex = PieceSize_->count () - 1;

				PieceSize_->setCurrentIndex (shouldIndex);

				on_PieceSize__currentIndexChanged ();
			}
开发者ID:Akon32,项目名称:leechcraft,代码行数:35,代码来源:thirdstep.cpp

示例5: load

bool QTranslator::load(const QString & filename, const QString & directory,
                       const QString & search_delimiters,
                       const QString & suffix)
{
    Q_D(QTranslator);
    d->clear();

    QString fname = filename;
    QString prefix;
    if (QFileInfo(filename).isRelative()) {
        prefix = directory;
        if (prefix.length() && !prefix.endsWith(QLatin1Char('/')))
            prefix += QLatin1Char('/');
    }


    QString realname;
    QString delims;
    delims = search_delimiters.isNull() ? QString::fromLatin1("_.") : search_delimiters;

    for (;;) {
        QFileInfo fi;


        realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix);
        fi.setFile(realname);
        if (fi.isReadable() && fi.isFile())
            break;

        realname = prefix + fname;
        fi.setFile(realname);
        if (fi.isReadable() && fi.isFile())
            break;

        int rightmost = 0;
        for (int i = 0; i < (int)delims.length(); i++) {
            int k = fname.lastIndexOf(delims[i]);
            if (k > rightmost)
                rightmost = k;
        }

        // no truncations? fail
        if (rightmost == 0)
            return false;

        fname.truncate(rightmost);
    }

    // realname is now the fully qualified name of a readable file.
    return d->do_load(realname);
}
开发者ID:fluxer,项目名称:katie,代码行数:51,代码来源:qtranslator.cpp

示例6: pathFi

void
CalamaresApplication::initSettings()
{
    QFileInfo settingsFile;
    if ( CalamaresUtils::isAppDataDirOverridden() )
    {
        settingsFile = QFileInfo( CalamaresUtils::appDataDir().absoluteFilePath( "settings.conf" ) );
        if ( !settingsFile.exists() || !settingsFile.isReadable() )
        {
            cLog() << "FATAL ERROR: explicitly configured application data directory"
                   << CalamaresUtils::appDataDir().absolutePath()
                   << "does not contain a valid settings.conf file."
                   << "\nCowardly refusing to continue startup without settings.";
            ::exit( EXIT_FAILURE );
        }
    }
    else
    {
        QStringList settingsFileCandidatesByPriority;
        if ( isDebug() )
        {
            settingsFileCandidatesByPriority.append(
                QDir::currentPath() +
                QDir::separator() +
                "settings.conf" );
        }
        settingsFileCandidatesByPriority.append( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/settings.conf" );
        settingsFileCandidatesByPriority.append( CalamaresUtils::appDataDir()
                                                    .absoluteFilePath( "settings.conf" ) );

        foreach ( const QString& path, settingsFileCandidatesByPriority )
        {
            QFileInfo pathFi( path );
            if ( pathFi.exists() && pathFi.isReadable() )
            {
                settingsFile = pathFi;
                break;
            }
        }

        if ( !settingsFile.exists() || !settingsFile.isReadable() )
        {
            cLog() << "FATAL ERROR: none of the expected configuration file paths ("
                   << settingsFileCandidatesByPriority.join( ", " )
                   << ") contain a valid settings.conf file."
                   << "\nCowardly refusing to continue startup without settings.";
            ::exit( EXIT_FAILURE );
        }
    }
开发者ID:toudi,项目名称:calamares,代码行数:49,代码来源:CalamaresApplication.cpp

示例7: findResourceInProject

/*
 * A more efficient way to do this would be to parse the relevant project files
 * before hand, or cache them as we go - but this works well enough so far.
 */
static QString findResourceInProject(const QString &resName)
{
    QString s = resName;
    s.remove('"');

    if (s.startsWith(":/"))
        s.remove(0, 1);
    else if (s.startsWith("qrc://"))
        s.remove(0, 5);
    else
        return QString();

    if (auto *project = ProjectExplorer::ProjectTree::currentProject()) {
        const Utils::FileNameList files = project->files(ProjectExplorer::Project::AllFiles);
        for (const Utils::FileName &file : files) {
            if (!file.endsWith(".qrc"))
                continue;
            const QFileInfo fi = file.toFileInfo();
            if (!fi.isReadable())
                continue;
            const QString fileName = findResourceInFile(s, file.toString());
            if (fileName.isEmpty())
                continue;

            QString ret = fi.absolutePath();
            if (!ret.endsWith('/'))
                ret.append('/');
            ret.append(fileName);
            return ret;
        }
    }

    return QString();
}
开发者ID:kai66673,项目名称:qt-creator,代码行数:38,代码来源:resourcepreviewhoverhandler.cpp

示例8: directory

void
DialogCleanup::Cleanup(
	)
{
	// Get size before.
	unsigned int startSize = FileUtils::GetFolderSize( m_Path );
	m_UI.output->appendPlainText( "Cleaning '" + m_Path + "' ..." );

	// Go through files.
	QDir directory( m_Path );
	QFileInfoList files = directory.entryInfoList();
	for ( QFileInfoList::iterator i = files.begin(); i != files.end(); i++ ) {
		QFileInfo file = *i;
		if ( !file.isReadable() ) continue;
		if ( file.fileName() == "." || file.fileName() == ".." ) continue;
		if ( std::find( m_Preserved.begin(), m_Preserved.end(), file.fileName() ) == m_Preserved.end() ) {
			m_UI.output->appendPlainText( "Removing: " + file.fileName() );
			if ( file.isDir() ) FileUtils::DeleteFolder( file.absoluteFilePath() );
			if ( file.isFile() ) QFile::remove(file.absoluteFilePath());
		}
	}

	// Get size after.
	unsigned int endSize = FileUtils::GetFolderSize( m_Path );
	m_UI.output->appendPlainText( "Cleaning complete." );
	m_UI.output->appendPlainText( "Cleaned " + QString::number( startSize - endSize ) + " megabytes." );

	// Change UI to reflect completion.
	m_UI.btnDone->setText( "Close" );
}
开发者ID:NullCascade,项目名称:Infinity-Engine-Modlist-Installer,代码行数:30,代码来源:DialogCleanup.cpp

示例9: accept

	void AddTask::accept ()
	{
		QFileInfo dir (Ui_.LocalPath_->text ());
		QString message;
		if (!dir.exists ())
			message = tr ("Directory %1 doesn't exist, would you like to "
					"select another?").arg (dir.absolutePath ());
		else if (!dir.isReadable ())
			message = tr ("Directory %1 isn't readable, would you like to "
					"select another?").arg (dir.absolutePath ());
		else if (!dir.isWritable ())
			message = tr ("Directory %1 isn't writable, would you like to "
					"select another?").arg (dir.absolutePath ());
		else if (!dir.isDir ())
			message = tr ("%1 isn't a directory at all, would you like to "
					"select another?").arg (dir.absolutePath ());
		else
		{
			QDialog::accept ();
			return;
		}

		if (QMessageBox::question (this,
					"LeechCraft",
					message,
					QMessageBox::Ok | QMessageBox::Cancel) ==
				QMessageBox::Ok)
			on_BrowseButton__released ();
		else
			QDialog::reject ();
	}
开发者ID:AlexWMF,项目名称:leechcraft,代码行数:31,代码来源:addtask.cpp

示例10: openItem

void FolderNavigationWidget::openItem(const QModelIndex &srcIndex, bool openDirectoryAsProject)
{
    const QString fileName = m_fileSystemModel->fileName(srcIndex);
    if (fileName == QLatin1String("."))
        return;
    if (fileName == QLatin1String("..")) {
        // cd up: Special behaviour: The fileInfo of ".." is that of the parent directory.
        const QString parentPath = m_fileSystemModel->fileInfo(srcIndex).absoluteFilePath();
        setCurrentDirectory(parentPath);
        return;
    }
    const QString path = m_fileSystemModel->filePath(srcIndex);
    if (m_fileSystemModel->isDir(srcIndex)) {
        const QFileInfo fi = m_fileSystemModel->fileInfo(srcIndex);
        if (!fi.isReadable() || !fi.isExecutable())
            return;
        // Try to find project files in directory and open those.
        if (openDirectoryAsProject) {
            QDir dir(path);
            QStringList proFiles;
            foreach (const QFileInfo &i, dir.entryInfoList(ProjectExplorerPlugin::projectFileGlobs(), QDir::Files))
                proFiles.append(i.absoluteFilePath());
            if (!proFiles.isEmpty())
                Core::ICore::instance()->openFiles(proFiles);
            return;
        }
        // Change to directory
        setCurrentDirectory(path);
        return;
    }
    // Open file.
    Core::ICore::instance()->openFiles(QStringList(path));
}
开发者ID:AltarBeastiful,项目名称:qt-creator,代码行数:33,代码来源:foldernavigationwidget.cpp

示例11: on_treeFiles_doubleClicked

void FileBrowser::on_treeFiles_doubleClicked(QModelIndex index)
{
    QFileInfo info = model->fileInfo(index);
    if(!info.isReadable() || !info.isDir())
        return;
    setPath(info.canonicalFilePath());
}
开发者ID:TomStanczyk,项目名称:vstboard,代码行数:7,代码来源:filebrowser.cpp

示例12: GetIconThemes

void QtStyleManager::GetIconThemes(IconThemeList& iconThemes) const
{
  iconThemes.clear();
  iconThemes.push_back(IconTheme(QString( "<<default>>" )));

  QStringList iconSearchPaths = QIcon::themeSearchPaths();

  for(QStringList::Iterator pathIt = iconSearchPaths.begin(); pathIt != iconSearchPaths.end(); ++pathIt)
  {
    QDirIterator dirIt(*pathIt);
    while (dirIt.hasNext())
    {
      QString current = dirIt.next();
      QFileInfo info = dirIt.fileInfo();
      if (info.isDir() && info.isReadable())
      {
        QFileInfo themeFile( info.filePath() + QString("/index.theme") );
        if( themeFile.exists() && themeFile.isFile() && themeFile.isReadable() )
        {
          QString fileName = info.fileName();
          iconThemes.push_back( IconTheme(fileName) );
        }
      }
    }
  }
}
开发者ID:151706061,项目名称:MITK,代码行数:26,代码来源:berryQtStyleManager.cpp

示例13: handleDirectoryChanged

		void ResourceLoader::handleDirectoryChanged (const QString& path)
		{
			emit watchedDirectoriesChanged ();

			for (auto i = Entry2Paths_.begin (), end = Entry2Paths_.end (); i != end; ++i)
				i->removeAll (path);

			QFileInfo fi (path);
			if (fi.exists () &&
					fi.isDir () &&
					fi.isReadable ())
				ScanPath (path);

			QStringList toRemove;
			for (auto i = Entry2Paths_.begin (), end = Entry2Paths_.end (); i != end; ++i)
				if (i->isEmpty ())
					toRemove << i.key ();

			for (const auto& entry : toRemove)
			{
				Entry2Paths_.remove (entry);

				auto items = SubElemModel_->findItems (entry);
				for (auto item : SubElemModel_->findItems (entry))
					SubElemModel_->removeRow (item->row ());
			}
		}
开发者ID:ForNeVeR,项目名称:leechcraft,代码行数:27,代码来源:resourceloader.cpp

示例14: installMod

bool ModList::installMod ( const QFileInfo& filename, int index )
{
	if(!filename.exists() || !filename.isReadable() || index < 0)
	{
		return false;
	}
	Mod m(filename);
	if(!m.valid())
		return false;
	
	// if it's already there, replace the original mod (in place)
	int idx = mods.indexOf(m);
	if(idx != -1)
	{
		if(mods[idx].replace(m))
		{
			
			auto left = this->index(index);
			auto right = this->index(index, columnCount(QModelIndex()) - 1);
			emit dataChanged(left, right);
			saveListFile();
			emit changed();
			return true;
		}
		return false;
	}
	
	auto type = m.type();
	if(type == Mod::MOD_UNKNOWN)
		return false;
	if(type == Mod::MOD_SINGLEFILE || type == Mod::MOD_ZIPFILE)
	{
		QString newpath = PathCombine(m_dir.path(), filename.fileName());
		if(!QFile::copy(filename.filePath(), newpath))
			return false;
		m.repath(newpath);
		beginInsertRows(QModelIndex(), index, index);
		mods.insert(index,m);
		endInsertRows();
		saveListFile();
		emit changed();
		return true;
	}
	else if(type == Mod::MOD_FOLDER)
	{
		
		QString from = filename.filePath();
		QString to = PathCombine(m_dir.path(), filename.fileName());
		if(!copyPath(from, to))
			return false;
		m.repath(to);
		beginInsertRows(QModelIndex(), index, index);
		mods.insert(index,m);
		endInsertRows();
		saveListFile();
		emit changed();
		return true;
	}
	return false;
}
开发者ID:Apocalypsing,项目名称:MultiMC5,代码行数:60,代码来源:ModList.cpp

示例15: addFileNode

  tlp::node addFileNode(const QFileInfo &infos, tlp::Graph *g) {
    tlp::node n = g->addNode();
    _absolutePaths->setNodeValue(n,tlp::QStringToTlpString(infos.absoluteFilePath()));
    _baseNames->setNodeValue(n,tlp::QStringToTlpString(infos.baseName()));
    _createdDates->setNodeValue(n,tlp::QStringToTlpString(infos.created().toString()));
    _fileNames->setNodeValue(n,tlp::QStringToTlpString(infos.fileName()));
    _isDir->setNodeValue(n,infos.isDir());
    _isExecutable->setNodeValue(n,infos.isExecutable());
    _isReadable->setNodeValue(n,infos.isReadable());
    _isSymlink->setNodeValue(n,infos.isSymLink());
    _isWritable->setNodeValue(n,infos.isWritable());
    _lastModifiedDates->setNodeValue(n,tlp::QStringToTlpString(infos.lastModified().toString()));
    _lastReadDates->setNodeValue(n,tlp::QStringToTlpString(infos.lastRead().toString()));
    _owners->setNodeValue(n,tlp::QStringToTlpString(infos.owner()));
    _permissions->setNodeValue(n,(int)(infos.permissions()));
    _suffixes->setNodeValue(n,tlp::QStringToTlpString(infos.suffix()));
    _sizes->setNodeValue(n,infos.size());

    if (_useIcons) {
      std::string extension = infos.suffix().toStdString();

      if (infos.isDir()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FolderO);
        tlp::ColorProperty *viewColor = graph->getProperty<tlp::ColorProperty>("viewColor");
        viewColor->setNodeValue(n, dirColor);
      }
      else if (std::find(commonTextFilesExt.begin(), commonTextFilesExt.end(), extension) != commonTextFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileTextO);
      }
      else if (std::find(commonArchiveFilesExt.begin(), commonArchiveFilesExt.end(), extension) != commonArchiveFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileArchiveO);
      }
      else if (std::find(commonAudioFilesExt.begin(), commonAudioFilesExt.end(), extension) != commonAudioFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileAudioO);
      }
      else if (std::find(commonImageFilesExt.begin(), commonImageFilesExt.end(), extension) != commonImageFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileImageO);
      }
      else if (std::find(commonVideoFilesExt.begin(), commonVideoFilesExt.end(), extension) != commonVideoFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileVideoO);
      }
      else if (std::find(commonDevFilesExt.begin(), commonDevFilesExt.end(), extension) != commonDevFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileCodeO);
      }
      else if (extension == "pdf") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FilePdfO);
      }
      else if (extension == "doc" || extension == "docx") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileWordO);
      }
      else if (extension == "xls" || extension == "xlsx") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileExcelO);
      }
      else if (extension == "ppt" || extension == "pptx") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FilePowerpointO);
      }
    }

    return n;
  }
开发者ID:mneumann,项目名称:tulip,代码行数:60,代码来源:FileSystem.cpp


注:本文中的QFileInfo::isReadable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。