本文整理汇总了C++中QFileInfoList::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfoList::clear方法的具体用法?C++ QFileInfoList::clear怎么用?C++ QFileInfoList::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileInfoList
的用法示例。
在下文中一共展示了QFileInfoList::clear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: url
bool Ilwis3CatalogConnector::loadItems()
{
QUrl location = _location.url();
QStringList namefilter;
namefilter << "*.mpr" << "*.mpa" << "*.mps" << "*.mpp" << "*.tbt" << "*.dom" << "*.rpr" << "*.csy" << "*.grf" << "*.mpl";
QFileInfoList fileList = loadFolders(namefilter);
// remove duplicates, shoudnt happen but better save than sorry
QSet<QFileInfo> reduced = fileList.toSet();
fileList.clear();
fileList = QList<QFileInfo>::fromSet(reduced);
QList<ODFItem> odfitems;
QList<Resource> folders;
QHash<QString, quint64> names;
foreach(QFileInfo file, fileList) {
QUrl container = location.url();
QString path = file.canonicalFilePath();
QString loc = container.toLocalFile();
if ( path.compare(loc,Qt::CaseInsensitive) == 0)
container = file.canonicalPath();
IlwisTypes tp = Ilwis3Connector::ilwisType(path);
QUrl url("file:///" + path);
if ( mastercatalog()->resource2id(url, tp) == i64UNDEF) {
if ( tp & itILWISOBJECT ) {
ODFItem item(path);
odfitems.push_back(item);
names[file.fileName().toLower()] = item.id();
} else {
folders.push_back(loadFolder(file, container, path, url));
}
}
}
示例2: get_copyTgt_List
/*
* name : get_copyTgt_List
* desc : Scan whole source list and target path,
* if path has existed and optionOverwrite is off,
* the source path would removed from list
*/
void PicIn_Core::get_copyTgt_List(void)
{
QFile file;
QString tgtName;
QString tgtPath;
QString yearPath;
QString monthPath;
QString dayPath;
QString srcPath;
QDate date;
QDir dir;
QFileInfoList tempSrcList;
tempSrcList.clear();
m_copyTgtList.clear();
for(int i = 0; i < m_fileInfoList_src.size(); i++){
srcPath = m_fileInfoList_src.at(i).absoluteFilePath();
tgtName.clear();
tgtName.append(m_fileInfoList_src.at(i).fileName());
tgtPath.clear();
tgtPath.append(m_pathList_target.at(0)); // Only support 1 target path
//
// Check whether need to separate pics to folders as date
//
if(checkOption(optionExifDate)){
date = getExifDate(srcPath);
}
if(!date.isValid() || !checkOption(optionExifDate)){
date = m_fileInfoList_src.at(i).lastModified().date();
}
yearPath.clear();
monthPath.clear();
dayPath.clear();
if(checkOption(optionDirYear)){
yearPath.sprintf("/%04d/", date.year());
tgtPath.append(yearPath);
}
if(checkOption(optionDirMon)){
monthPath.sprintf("/%02d/", date.month());
tgtPath.append(monthPath);
}
if(checkOption(optionDirDay)){
dayPath.sprintf("/%02d/", date.day());
tgtPath.append(dayPath);
}
//
// Check whether file need to be copied
//
tgtPath.append(tgtName);
if(!file.exists(tgtPath) || checkOption(optionOverwrite)){
m_copyTgtList.append(tgtPath);
tempSrcList.append(m_fileInfoList_src.at(i));
}
}
m_fileInfoList_src = tempSrcList;
return;
}
示例3: GetEntryLists
static PRL_RESULT GetEntryLists(
const QString & aVmHomeDir,
QList<QPair<QFileInfo, QString> > & dirList,
QList<QPair<QFileInfo, QString> > & fileList)
{
QString VmHomeDir = QFileInfo(aVmHomeDir).absoluteFilePath();
QFileInfo dirInfo;
QFileInfoList entryList;
QDir dir;
QDir startDir(VmHomeDir);
int i, j;
QFileInfo config, config_backup, log, statlog;
config.setFile(VmHomeDir, VMDIR_DEFAULT_VM_CONFIG_FILE);
config_backup.setFile(VmHomeDir, VMDIR_DEFAULT_VM_CONFIG_FILE VMDIR_DEFAULT_VM_BACKUP_SUFFIX);
log.setFile(VmHomeDir, "parallels.log");
statlog.setFile(VmHomeDir, PRL_VMTIMING_LOGFILENAME);
dirInfo.setFile(VmHomeDir);
if (!dirInfo.exists()) {
WRITE_TRACE(DBG_FATAL, "Directory %s does not exist", QSTR2UTF8(VmHomeDir));
return (PRL_ERR_VMDIR_INVALID_PATH);
}
dirList.append(qMakePair(dirInfo, QString(".")));
for (i = 0; i < dirList.size(); ++i) {
/* CDir::absoluteDir() is equal CDir::dir() : return parent directory */
dir.setPath(dirList.at(i).first.absoluteFilePath());
entryList = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs | QDir::Hidden);
WRITE_TRACE(DBG_DEBUG, "Directory %s", QSTR2UTF8(dirList.at(i).first.absoluteFilePath()));
for (j = 0; j < entryList.size(); ++j) {
const QFileInfo& fileInfo = entryList.at(j);
if (dirInfo == fileInfo) {
WRITE_TRACE(DBG_FATAL, "Infinite recursion in : %s", QSTR2UTF8(dirInfo.absoluteFilePath()));
return (PRL_ERR_FAILURE);
}
if (!fileInfo.absoluteFilePath().startsWith(VmHomeDir)) {
WRITE_TRACE(DBG_FATAL, "Path %s does not starts from VM home dir (%s)",
QSTR2UTF8(fileInfo.absoluteFilePath()),
QSTR2UTF8(VmHomeDir));
return PRL_ERR_FAILURE;
}
;
if (fileInfo.isDir()) {
dirList.append(qMakePair(
fileInfo, startDir.relativeFilePath(fileInfo.absoluteFilePath())));
} else {
/* skip config & config backup */
if (fileInfo.absoluteFilePath() == config.absoluteFilePath())
continue;
if (fileInfo.absoluteFilePath() == config_backup.absoluteFilePath())
continue;
/* skip parallels.log */
if (fileInfo.absoluteFilePath() == log.absoluteFilePath())
continue;
if (fileInfo.absoluteFilePath() == statlog.absoluteFilePath())
/* will save statistic.log to temporary file */
fileList.append(qMakePair(statlog,
QString(PRL_VMTIMING_LOGFILENAME VMDIR_DEFAULT_VM_MIGRATE_SUFFIX)));
else
fileList.append(qMakePair(
fileInfo, startDir.relativeFilePath(fileInfo.absoluteFilePath())));
}
WRITE_TRACE(DBG_DEBUG, "%x\t%s.%s\t%s",
int(fileInfo.permissions()),
QSTR2UTF8(fileInfo.owner()),
QSTR2UTF8(fileInfo.group()),
QSTR2UTF8(fileInfo.absoluteFilePath()));
}
entryList.clear();
}
/* remove VM home directory */
dirList.removeFirst();
return (PRL_ERR_SUCCESS);
}
示例4: getMaskToConfig
QString OptionsWindow::getMaskToConfig(int step) {
QString mask;
QSettings *GlobalSettings = new QSettings("/root/.WiFiHostapdAP/WiFi_Hostapd_AP.conf",QSettings::NativeFormat); // создание нового объекта
QDir dir;
QFileInfoList list;
QString temp_qstring = "default.conf";
QString path;
switch(step) {
case 0:
dir.cd("/root");
if(!dir.cd(".WiFiHostapdAP")) {
dir.mkdir(QString("%1").arg(".WiFiHostapdAP"));
dir.cd(".WiFiHostapdAP"); }
if(!dir.cd("./Mask/")) {
dir.mkdir(QString("%1").arg("Mask"));
dir.cd("./Mask/"); }
if(!dir.cd("./hostapd/")) {
dir.mkdir(QString("%1").arg("hostapd"));
dir.cd("./hostapd/"); }
dir.setFilter(QDir::Files);
list = dir.entryInfoList();
if(list.size()==0) {
QFile new_Default_Mask("/root/.WiFiHostapdAP/Mask/hostapd/default.conf");
new_Default_Mask.open(QIODevice::Append | QIODevice::Text);
QTextStream out(&new_Default_Mask);
out << "#Name:Default\n";
out << "#Type:Hostapd\n";
out << "interface=[INTERFACE]\n";
out << "driver=[DRIVER]\n";
out << "ssid=[SSID]\n";
out << "country_code=[COUNTRY_CODE]\n";
out << "[TYPE_AP]\n";
out << "channel=[CHANNEL]\n";
out << "macaddr_acl=0\n";
out << "[HIDEAP]\n";
out << "[PROTECT]";
new_Default_Mask.close();
list.clear();
dir.setFilter(QDir::Files);
list = dir.entryInfoList();
}
path = "/root/.WiFiHostapdAP/Mask/hostapd/";
for (int i = 0; i < list.size(); ++i) {
QFileInfo fileInfo = list.at(i);
if(fileInfo.fileName() == GlobalSettings->value("AP/ConfigMask", "default.conf").toString())
temp_qstring = GlobalSettings->value("AP/ConfigMask", "default.conf").toString();
}
path += temp_qstring;
break;
case 1:
dir.cd("/root");
if(!dir.cd(".WiFiHostapdAP")) {
dir.mkdir(QString("%1").arg(".WiFiHostapdAP"));
dir.cd(".WiFiHostapdAP"); }
if(!dir.cd("./Mask/")) {
dir.mkdir(QString("%1").arg("Mask"));
dir.cd("./Mask/"); }
if(!dir.cd("./dnsmasq/")) {
dir.mkdir(QString("%1").arg("dnsmasq"));
dir.cd("./dnsmasq/"); }
dir.setFilter(QDir::Files);
list = dir.entryInfoList();
if(list.size()==0) {
// If the pattern is not present, create the default template
QFile new_Default_Mask("/root/.WiFiHostapdAP/Mask/dnsmasq/default.conf");
new_Default_Mask.open(QIODevice::Append | QIODevice::Text);
QTextStream out(&new_Default_Mask);
out << "#Name:Default\n";
out << "#Type:DNSMASQ\n";
out << "interface=[INTERFACE]\n";
out << "dhcp-range=[RANGE_1],[RANGE_2],[IP_TIME];\n";
out<< "[OpenDNS]";
new_Default_Mask.close();
list.clear();
dir.setFilter(QDir::Files);
list = dir.entryInfoList();
}
path = "/root/.WiFiHostapdAP/Mask/dnsmasq/";
for (int i = 0; i < list.size(); ++i) {
QFileInfo fileInfo = list.at(i);
if(fileInfo.fileName() == GlobalSettings->value("AP/ConfigMask1", "default.conf").toString())
temp_qstring = GlobalSettings->value("AP/ConfigMask1", "default.conf").toString();
//.........这里部分代码省略.........
示例5: testLibrary
bool QAudioManager::testLibrary(QAbstractCoder *coder)
{
setError(QCoder::NoError);
QStringList nameFilters;
QDir::Filters filters = QDir::Files | QDir::NoDotAndDotDot;
QDir dir;
QFileInfoList possibles;
QStringList fileNames = coder->fileNames();
QStringList fileExtensions = coder->fileExtensions();
for(int j = 0; j < mSearchPaths.size(); ++j)
{
QString path = mSearchPaths[j];
for(int k = 0; k < fileNames.size(); ++k)
{
QString fileName = fileNames[k];
for(int h = 0; h < fileNames.size(); ++h)
{
QString directoryName = fileNames[h];
for(int i = 0; i < fileExtensions.size(); ++i)
{
if( coder->load(path + fileName + fileExtensions[i]) == QCoder::NoError ||
coder->load(path + "lib" + fileName + fileExtensions[i]) == QCoder::NoError ||
coder->load(path + directoryName + QDir::separator() + fileName + fileExtensions[i]) == QCoder::NoError ||
coder->load(path + directoryName + QDir::separator() + "lib" + fileName + fileExtensions[i]) == QCoder::NoError ||
coder->load(path + "lib" + directoryName + QDir::separator() + fileName + fileExtensions[i]) == QCoder::NoError ||
coder->load(path + "lib" + directoryName + QDir::separator() + "lib" + fileName + fileExtensions[i]) == QCoder::NoError)
{
coder->unload();
add(QAudioManager::Available, coder);
return true;
}
//Check for libraries that end in version number. Eg: libflac.so.8
nameFilters.clear();
possibles.clear();
nameFilters << fileName + fileExtensions[i] + "*";
nameFilters << "lib" + fileName + fileExtensions[i] + "*";
dir.setPath(path);
possibles.append(dir.entryInfoList(nameFilters, filters, QDir::Name));
dir.setPath(path + directoryName);
possibles.append(dir.entryInfoList(nameFilters, filters, QDir::Name));
dir.setPath(path + "lib" + directoryName);
possibles.append(dir.entryInfoList(nameFilters, filters, QDir::Name));
for(int t = 0; t < possibles.size(); ++t)
{
if(coder->load(possibles[t].absoluteFilePath()) == QCoder::NoError)
{
coder->unload();
add(QAudioManager::Available, coder);
return true;
}
}
}
}
}
}
return false;
}
示例6: verificarModulos
bool chksysTimer::verificarModulos()
{
QDir dir(this->cacicFolder + "/temp");
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks | QDir::Executable);
dir.setSorting(QDir::Size | QDir::Reversed);
bool serviceUpdate;
QFileInfoList list = dir.entryInfoList();
for (int i = 0; i<list.size(); i++){
serviceUpdate = false;
//Se o módulo for install-cacic, deverá ficar na pasta "/bin"
QFile novoModulo(list.at(i).filePath());
#ifdef Q_OS_WIN
if (QFile::exists(this->cacicFolder + "/" + (list.at(i).fileName().contains("install-cacic") ?
"bin/" + list.at(i).fileName() :
list.at(i).fileName()))){
#else
if (QFile::exists(this->cacicFolder + "/" + list.at(i).fileName())){
#endif
if (list.at(i).fileName().contains("cacic-service")){
#ifdef Q_OS_WIN
ServiceController *service = new ServiceController(QString(CACIC_SERVICE_NAME).toStdWString());
if (service->isRunning()) {
log->escrever(LogCacic::InfoLevel, "Serviço rodando.. parando servico");
if (!service->stop()) {
std::string info = "Falha ao parar serviço. Info: ";
info+= service->getLastError();
log->escrever(LogCacic::ErrorLevel, info.c_str());
}
}
delete service;
service = NULL;
#else
ConsoleObject console;
if (CCacic::findProc("cacic-service")) console("killall -9 \"cacic-service\"");
#endif
}
#ifdef Q_OS_WIN
QFile::remove(this->cacicFolder + "/" + (list.at(i).fileName().contains("install-cacic") ?
"bin/" + list.at(i).fileName() :
list.at(i).fileName()));
#else
QFile::remove(this->cacicFolder + "/" + list.at(i).fileName());
#endif
//Garante a exclusão. às vezes o SO demora a reconhecer, dunno why.
QThread::sleep(1);
}
#ifdef Q_OS_WIN
if (!QFile::exists(this->cacicFolder + "/" + (list.at(i).fileName().contains("install-cacic") ?
"bin/" + list.at(i).fileName() :
list.at(i).fileName()))){
novoModulo.copy(this->cacicFolder + "/" + (list.at(i).fileName().contains("install-cacic") ?
"bin/" + list.at(i).fileName() :
list.at(i).fileName()));
#else
if (!QFile::exists(this->cacicFolder + "/" + list.at(i).fileName())){
novoModulo.copy(this->cacicFolder + "/" + list.at(i).fileName());
#endif
if (!novoModulo.remove())
log->escrever(LogCacic::ErrorLevel, "Falha ao excluir "+list.at(i).fileName()+" da pasta temporária.");
else {
log->escrever(LogCacic::InfoLevel, "Módulo \"" + list.at(i).filePath() + "\" atualizado.");
if (list.at(i).fileName().contains("cacic-service") && serviceUpdate){
#ifdef Q_OS_WIN
ServiceController *service = new ServiceController(QString("cacicdaemon").toStdWString());
if (!service->isRunning()) service->start();
#else
ConsoleObject console;
if (!CCacic::findProc("cacic-service")) console("/etc/init.d/cacic3 start");
#endif
}
}
} else {
log->escrever(LogCacic::ErrorLevel, "Falha ao excluir módulo antigo"+list.at(i).fileName()+" da pasta temporária.");
}
novoModulo.close();
}
list.clear();
return true;
}
示例7: copyFolder
void FileManager::copyFolder(QString scrPath, QString dstPath)
{
QFileInfoList fList;
fList.clear();
getFolderFiles(scrPath, fList);
if(fList.size() == 0)
{
//QMessageBox::warning(this, tr("Error"), tr("文件夹是空的:").arg(scrPath), 0, 0);
qDebug() << tr("文件夹是空的:").arg(srcfileName);
return;
}
if(srcfileName.compare(destinationPath) == 0) return;
bool stopped = false;
int curIndex = 0;
while( !stopped )
{
if( curIndex == fList.size() )
{
stopped = true;
continue;
}
QFileInfo curFileInfo = fList.at(curIndex);
QString srcFileName = curFileInfo.filePath();
QFile src(srcFileName);
QFileInfo srcTmp(srcfileName);
QString srcTripname = srcFileName.remove(srcfileName);
QString dstFileName = srcTripname.insert(0, dstPath+srcTmp.fileName());
QFile dst(dstFileName);
QFileInfo tmp(dstFileName);
qDebug() << tmp.path();
QDir d(tmp.path());
if(!d.exists())
d.mkpath(d.absolutePath());
//now copy
if(!src.open(QFile::ReadOnly) || !dst.open(QFile::WriteOnly)) continue;
fileSize = src.bytesAvailable();
qint64 BUFF_SIZE = 61440;
char* buffer = new char[BUFF_SIZE];
//int oldPercent = 0;
while( !src.atEnd() )
{
dst.write(buffer, src.read(buffer, BUFF_SIZE));
//dst.flush();
}
src.close();
dst.close();
delete[] buffer;
buffer = NULL;
curIndex++;
int percent = (curIndex*100) / fList.size();//((curIndex + 1) * 100) / fileSize;
//if (oldPercent != percent)
{
emit verificationProgressSignal(percent);
//oldPercent = percent;
}
}
fList.clear();
}