本文整理汇总了C++中qfileinfolist::iterator::fileName方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::fileName方法的具体用法?C++ iterator::fileName怎么用?C++ iterator::fileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qfileinfolist::iterator
的用法示例。
在下文中一共展示了iterator::fileName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkChanges
void Watcher::checkChanges(const QString& path) { // Getting name of appeared file
delete dir;
dir = new QDir(path);
listOfFiles = dir->entryInfoList();
qDebug() << "Изменения в каталоге";
qDebug() << listOfFiles.length() << oldLength << "\n";
if (listOfFiles.length() > oldLength) {
QFileInfoList::iterator i;
QFileInfoList::iterator j;
for (j = oldListOfFiles.begin(); j != oldListOfFiles.end(); ++j)
{
for (i = listOfFiles.begin(); i != listOfFiles.end(); ++i)
{
if (i->fileName().compare(j->fileName()) == 0)
{
listOfFiles.erase(i);
break;
}
}
}
qDebug() << listOfFiles.first().fileName();
dialog = new Dialog(listOfFiles.first(), this);
dialog->show();
setLabel(listOfFiles.first().fileName()); // Showing bubble notification in tray
}
oldListOfFiles = dir->entryInfoList();
oldLength = oldListOfFiles.length();
}
示例2: removeDir
bool VideoMetadataImp::removeDir(const QString &dirName)
{
QDir d(dirName);
QFileInfoList contents = d.entryInfoList();
if (!contents.size())
{
return d.rmdir(dirName);
}
for (QFileInfoList::iterator p = contents.begin(); p != contents.end(); ++p)
{
if (p->fileName() == "." ||
p->fileName() == "..")
{
continue;
}
if (p->isDir())
{
QString fileName = p->fileName();
if (!removeDir(fileName))
return false;
}
else
{
if (!QFile(p->fileName()).remove())
return false;
}
}
return d.rmdir(dirName);
}
示例3: rollbackDocumentsTransition
void UniboardSankoreTransition::rollbackDocumentsTransition(QFileInfoList& fileInfoList)
{
QFileInfoList::iterator fileInfo;
for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
if (fileInfo->isDir() && fileInfo->fileName().startsWith("Uniboard Document ")){
QString sankoreDocumentName = fileInfo->fileName();
sankoreDocumentName.replace("Uniboard","Sankore");
QString sankoreDocumentDirectoryPath = UBSettings::userDocumentDirectory() + "/" + sankoreDocumentName;
if (QFileInfo(sankoreDocumentDirectoryPath).exists()){
UBFileSystemUtils::deleteDir(sankoreDocumentDirectoryPath);
}
}
}
}
示例4: removeFileWithDir
/*递归删除文件夹内容
**
**dir :文件夹的名字,绝对路径和相对路径均可
**
**返回值 :成功后返回true;否则返回false
*/
bool removeFileWithDir(const QString &dirName)
{
static QVector<QString> dirNames;
QDir dir;
QFileInfoList filst;
QFileInfoList::iterator curFi;
//初始化
dirNames.clear();
if(dir.exists()){
dirNames<<dirName;
}
else{
return true;
}
//遍历各级文件夹,并将这些文件夹中的文件删除
for(int i=0;i<dirNames.size();++i)
{
dir.setPath(dirNames[i]);
filst=dir.entryInfoList(QDir::Dirs|QDir::Files
|QDir::Readable|QDir::Writable
|QDir::Hidden|QDir::NoDotAndDotDot
,QDir::Name);
if(filst.size()>0)
{
curFi=filst.begin();
while(curFi!=filst.end())
{
//遇到文件夹,则添加至文件夹列表dirs尾部
if(curFi->isDir())
{
dirNames.push_back(curFi->filePath());
}
else if(curFi->isFile())
{
//遇到文件,则删除之
if(!dir.remove(curFi->fileName()))
{
//return false;
}
}
curFi++;
}//end of while
}
}
#if 0
//删除文件夹
for(int i=dirNames.size()-1;i>=0;--i)
{
if(!dir.rmdir(dirNames[i]))
{
//return false;
}
}
#endif
return true;
}
示例5: processCacheCleaning
void LunarMainWindow::processCacheCleaning()
{
QDir dir("cache/");
QFileInfoList listDir = dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
int i = 0;
for(QFileInfoList::iterator it = listDir.begin(); it != listDir.end(); ++it)
{
if(it->lastModified().date() <= m_cacheDuration)
{
qDebug() << it->lastModified().date() << " " << m_cacheDuration << endl;
QFile file("cache/" + it->fileName());
file.remove();
i++;
}
}
qDebug() << "Cleaned " << i << " expired elements from the cache" << endl;
}
示例6: SearchDirContianSuffix
bool PathManager::SearchDirContianSuffix(const QString &dirFrom, QStringList &result, QString &suffix)
{
QVector<QString> dirNames;
QDir dir(dirFrom);
QFileInfoList filst;
QFileInfoList::iterator curFi;
//初始化
dirNames.clear();
if (dir.exists()){
dirNames << dirFrom;
}
else{
return true;
}
//遍历各级文件夹,并将这些文件夹中的文件删除
for (int i = 0; i < dirNames.size(); ++i)
{
dir.setPath(dirNames[i]);
filst = dir.entryInfoList(QDir::Dirs | QDir::Files
| QDir::Readable | QDir::Writable
| QDir::Hidden | QDir::NoDotAndDotDot
, QDir::DirsFirst);
if (filst.size()>0){
curFi = filst.begin();
while (curFi != filst.end())
{
//遇到文件夹,则添加至文件夹列表dirs尾部
if (curFi->isDir()){
dirNames.push_back(curFi->filePath());
}
else if (curFi->isFile()){
if (curFi->fileName().endsWith(suffix)){
result.push_back(curFi->absolutePath());
break;
}
}
curFi++;
}//end of while
}
}
return true;
}
示例7: scanFS
void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString & currVirtualPath, const QSet<QUrl> &pFavoriteSet)
{
// Q_ASSERT(QFileInfo(currentPath.toLocalFile()).exists());
// if(QFileInfo(currentPath.toLocalFile()).exists())
// return;
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile());
QFileInfoList::iterator fileInfo;
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
if (abort) {
return;
}
QString fullFileName = fileInfo->absoluteFilePath();
UBFeatureElementType featureType = UBFeaturesController::fileTypeFromUrl(fullFileName);
QString fileName = fileInfo->fileName();
QImage icon = UBFeaturesController::getIcon(fullFileName, featureType);
if ( fullFileName.contains(".thumbnail."))
continue;
UBFeature testFeature(currVirtualPath + "/" + fileName, icon, fileName, QUrl::fromLocalFile(fullFileName), featureType);
emit sendFeature(testFeature);
emit featureSent();
emit scanPath(fullFileName);
if ( pFavoriteSet.find(QUrl::fromLocalFile(fullFileName)) != pFavoriteSet.end()) {
//TODO send favoritePath from the controller or make favoritePath public and static
emit sendFeature(UBFeature( UBFeaturesController::favoritePath + "/" + fileName, icon, fileName, QUrl::fromLocalFile(fullFileName), featureType));
}
if (featureType == FEATURE_FOLDER) {
scanFS(QUrl::fromLocalFile(fullFileName), currVirtualPath + "/" + fileName, pFavoriteSet);
}
}
}
示例8: GetFileInfoList
QStringList StorageGroup::GetFileInfoList(QString Path)
{
QStringList files;
QString relPath;
bool badPath = true;
if (Path.isEmpty() || Path == "/")
{
for (QStringList::Iterator it = m_dirlist.begin(); it != m_dirlist.end(); ++it)
files << QString("sgdir::%1").arg(*it);
return files;
}
for (QStringList::Iterator it = m_dirlist.begin(); it != m_dirlist.end(); ++it)
{
if (Path.startsWith(*it))
{
relPath = Path;
relPath.replace(*it,"");
if (relPath.startsWith("/"))
relPath.replace(0,1,"");
badPath = false;
}
}
LOG(VB_FILE, LOG_INFO, LOC +
QString("GetFileInfoList: Reading '%1'").arg(Path));
if (badPath)
return files;
QDir d(Path);
if (!d.exists())
return files;
QFileInfoList list = d.entryInfoList();
if (!list.size())
return files;
for (QFileInfoList::iterator p = list.begin(); p != list.end(); ++p)
{
if (p->fileName() == "." ||
p->fileName() == ".." ||
p->fileName() == "Thumbs.db")
{
continue;
}
QString tmp;
if (p->isDir())
tmp = QString("dir::%1::0").arg(p->fileName());
else
tmp = QString("file::%1::%2::%3%4").arg(p->fileName()).arg(p->size())
.arg(relPath).arg(p->fileName());
LOG(VB_FILE, LOG_DEBUG, LOC +
QString("GetFileInfoList: (%1)").arg(tmp));
files.append(tmp);
}
return files;
}
示例9: startUpdateCheck
void Application::startUpdateCheck(bool forceWait) {
updateCheckTimer.stop();
if (updateRequestId || updateThread || updateReply || !cAutoUpdate()) return;
int32 updateInSecs = cLastUpdateCheck() + 3600 + (rand() % 3600) - unixtime();
bool sendRequest = (updateInSecs <= 0 || updateInSecs > 7200);
if (!sendRequest && !forceWait) {
QDir updates(cWorkingDir() + "tupdates");
if (updates.exists()) {
QFileInfoList list = updates.entryInfoList(QDir::Files);
for (QFileInfoList::iterator i = list.begin(), e = list.end(); i != e; ++i) {
if (QRegularExpression("^(tupdate|tmacupd|tlinuxupd|tlinux32upd)\\d+$", QRegularExpression::CaseInsensitiveOption).match(i->fileName()).hasMatch()) {
sendRequest = true;
}
}
}
}
if (cManyInstance() && !cDebug()) return; // only main instance is updating
if (sendRequest) {
QNetworkRequest checkVersion(cUpdateURL());
if (updateReply) updateReply->deleteLater();
App::setProxySettings(updateManager);
updateReply = updateManager.get(checkVersion);
connect(updateReply, SIGNAL(finished()), this, SLOT(updateGotCurrent()));
connect(updateReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(updateFailedCurrent(QNetworkReply::NetworkError)));
// updateRequestId = MTP::send(MTPhelp_GetAppUpdate(MTP_string(cApiDeviceModel()), MTP_string(cApiSystemVersion()), MTP_string(cApiAppVersion()), MTP_string(cApiLang())), rpcDone(&Application::onAppUpdate), rpcFail(&Application::onAppUpdateFail);
emit updateChecking();
} else {
updateCheckTimer.start((updateInSecs + 5) * 1000);
}
}
示例10: updateGotCurrent
void Application::updateGotCurrent() {
if (!updateReply || updateThread) return;
cSetLastUpdateCheck(unixtime());
QRegularExpressionMatch m = QRegularExpression(qsl("^\\s*(\\d+)\\s*:\\s*([\\x21-\\x7f]+)\\s*$")).match(QString::fromUtf8(updateReply->readAll()));
if (m.hasMatch()) {
int32 currentVersion = m.captured(1).toInt();
if (currentVersion > AppVersion) {
updateThread = new QThread();
connect(updateThread, SIGNAL(finished()), updateThread, SLOT(deleteLater()));
updateDownloader = new PsUpdateDownloader(updateThread, m.captured(2));
updateThread->start();
}
}
if (updateReply) updateReply->deleteLater();
updateReply = 0;
if (!updateThread) {
QDir updates(cWorkingDir() + "tupdates");
if (updates.exists()) {
QFileInfoList list = updates.entryInfoList(QDir::Files);
for (QFileInfoList::iterator i = list.begin(), e = list.end(); i != e; ++i) {
if (QRegularExpression("^(tupdate|tmacupd|tlinuxupd|tlinux32upd)\\d+$", QRegularExpression::CaseInsensitiveOption).match(i->fileName()).hasMatch()) {
QFile(i->absoluteFilePath()).remove();
}
}
}
emit updateLatest();
}
startUpdateCheck(true);
App::writeConfig();
}
示例11: countSize
qint64 Dialog::countSize(QString filePath)
{
qint64 fileSize = 0;
QList<QString> fileList;
QFileInfo fileInfo(filePath);
QString strTopDir;
if(fileInfo.isDir()) {//文件夹加入堆栈
m_bFolder = true;
if (filePath.contains('/'))
{
QStringList strList = filePath.split("/");
int iSize = strList.size();
strTopDir = strList.at(iSize-1);
}
else if(filePath.contains('\\'))
{
QStringList strList = filePath.split("\\");
int iSize = strList.size();
strTopDir = strList.at(iSize-1);
}
fileList.push_back(filePath);
} else {//如果是文件的话就取文件的特特征码,文件特征码用文件的创建,最后的修改时间字符串和文件的路径取MD5
m_bFolder = false;
m_fileList.push_front(filePath);
fileSize = fileInfo.size();
QString createTime = fileInfo.created().toString();
QString modifiedTime = fileInfo.lastModified().toString();
QString checkString = createTime + modifiedTime;
checkString += filePath;
//m_fileCheck = MD5String(checkString.toLocal8Bit().data());
}
while(!fileList.isEmpty()){//判断堆栈中是否有文件夹
QString filePath = fileList.value(0);//取堆栈的顶部位置
QDir dir(filePath);//文件夹信息
dir.setFilter(QDir::Dirs|QDir::Files|QDir::Hidden|QDir::System);
dir.setSorting(QDir::DirsFirst);
QFileInfoList list = dir.entryInfoList();//去得文件夹的文件信息
QFileInfoList::iterator iter;
if (2 == list.size())
{
qDebug() << "empty dir : " << filePath;
m_emptyFolderList.push_back(filePath);
}
for(iter=list.begin(); iter!=list.end(); iter++) {//遍历文件夹内部
//m_stopMutex.lock();
// if(m_bStop) {
// m_stopMutex.unlock();
// return -1;
// }
// m_stopMutex.unlock();
//qDebug() << "filename : " << iter->fileName();
if(iter->fileName() == "." || iter->fileName() == "..") {
continue;
}
if(iter->isDir()) {//如果为文件夹的话加入到堆栈
fileList.push_back(iter->filePath());
} else {//如果是文件的话,取到文件的大小,并且把文件加入到发送list中
fileSize += iter->size();
//QString str
m_fileList.push_front(iter->filePath());
}
}
fileList.pop_front();//堆栈顶部的元素已经处理完毕,出堆栈
}
// if(m_fileCheck.size() == 0) {//文件夹的特征码是文件的所有路径取MD5
// QString checkString;
// QList<QString>::iterator iter;
// for(iter=m_fileList.begin(); iter!=m_fileList.end(); iter++) {
// checkString += (*iter);
// }
// m_fileCheck = MD5String(checkString.toLocal8Bit().data());
// }
qDebug() << "file or director size : " << fileSize;
return fileSize;
}
示例12: soInfo
QString
AudioPluginOSCGUI::getGUIFilePath(QString identifier)
{
QString type, soName, label;
PluginIdentifier::parseIdentifier(identifier, type, soName, label);
RG_DEBUG << "AudioPluginOSCGUI::getGUIFilePath(" << identifier << ")";
QFileInfo soInfo(soName);
if (soInfo.isRelative()) {
//!!!
RG_DEBUG << "AudioPluginOSCGUI::AudioPluginOSCGUI: Unable to deal with relative .so path \"" << soName << "\" in identifier \"" << identifier << "\" yet";
throw Exception("Can't deal with relative .soname");
}
QDir dir(soInfo.dir());
QString fileBase(soInfo.completeBaseName());
if (!dir.cd(fileBase)) {
RG_DEBUG << "AudioPluginOSCGUI::AudioPluginOSCGUI: No GUI subdir for plugin .so " << soName;
throw Exception("No GUI subdir available");
}
QFileInfoList list = dir.entryInfoList();
// in order of preference:
const char *suffixes[] = { "_rg", "_kde", "_qt", "_gtk2", "_gtk", "_x11", "_gui"
};
int nsuffixes = int(sizeof(suffixes) / sizeof(suffixes[0]));
for (int k = 0; k <= nsuffixes; ++k) {
for (int fuzzy = 0; fuzzy <= 1; ++fuzzy) {
QFileInfoList::iterator info;
for (info = list.begin(); info != list.end(); ++info) { //### JAS Check for errors
RG_DEBUG << "Looking at " << info->fileName() << " in path "
<< info->filePath() << " for suffix " << (k == nsuffixes ? "(none)" : suffixes[k]) << ", fuzzy " << fuzzy << endl;
if (!(info->isFile() || info->isSymLink())
|| !info->isExecutable()) {
RG_DEBUG << "(not executable)";
continue;
}
if (fuzzy) {
if (info->fileName().left(fileBase.length()) != fileBase)
continue;
RG_DEBUG << "(is file base)";
} else {
if (info->fileName().left(label.length()) != label)
continue;
RG_DEBUG << "(is label)";
}
if (k == nsuffixes || info->fileName().toLower().endsWith(suffixes[k])) {
RG_DEBUG << "(ends with suffix " << (k == nsuffixes ? "(none)" : suffixes[k]) << " or out of suffixes)";
return info->filePath();
}
RG_DEBUG << "(doesn't end with suffix " << (k == nsuffixes ? "(none)" : suffixes[k]) << ")";
}
}
}
return QString();
}