本文整理汇总了C++中qfileinfolist::iterator::absoluteFilePath方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::absoluteFilePath方法的具体用法?C++ iterator::absoluteFilePath怎么用?C++ iterator::absoluteFilePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qfileinfolist::iterator
的用法示例。
在下文中一共展示了iterator::absoluteFilePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReplacePakInDec
int PathManager::ReplacePakInDec(QString &path, QString &oldName, QString &newName)
{
QVector<QString> dirNames;
QDir dir(path);
QFileInfoList filst;
QFileInfoList::iterator curFi;
//初始化
dirNames.clear();
if (dir.exists()){
dirNames << path;
}
else{
return 0;
}
//遍历各级文件夹,并将这些文件夹中的文件删除
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 (curFi->absoluteFilePath().toLower().endsWith(".smali")){
if (!ReplacePakNameInSmali(curFi->absoluteFilePath(), oldName, newName)){
return 1;
}
}
else if (curFi->absoluteFilePath().toLower().endsWith(".xml")){
if (!ReplacePakNameInXml(path, curFi->absoluteFilePath(), oldName, newName)){
return 1;
}
}
}
curFi++;
}//end of while
}
}
int ret = 0;
ret = RenamePakInDec(path, oldName, newName);
if (ret != 0){
return ret;
}
return 0;
}
示例2: initOutput
void PsUpdateDownloader::initOutput() {
QString fileName;
QRegularExpressionMatch m = QRegularExpression(qsl("/([^/\\?]+)(\\?|$)")).match(updateUrl);
if (m.hasMatch()) {
fileName = m.captured(1).replace(QRegularExpression(qsl("[^a-zA-Z0-9_\\-]")), QString());
}
if (fileName.isEmpty()) {
fileName = qsl("tupdate-%1").arg(rand());
}
QString dirStr = cWorkingDir() + qsl("tupdates/");
fileName = dirStr + fileName;
QFileInfo file(fileName);
QDir dir(dirStr);
if (dir.exists()) {
QFileInfoList all = dir.entryInfoList(QDir::Files);
for (QFileInfoList::iterator i = all.begin(), e = all.end(); i != e; ++i) {
if (i->absoluteFilePath() != file.absoluteFilePath()) {
QFile::remove(i->absoluteFilePath());
}
}
} else {
dir.mkdir(dir.absolutePath());
}
outputFile.setFileName(fileName);
if (file.exists()) {
uint64 fullSize = file.size();
if (fullSize < INT_MAX) {
int32 goodSize = (int32)fullSize;
if (goodSize % UpdateChunk) {
goodSize = goodSize - (goodSize % UpdateChunk);
if (goodSize) {
if (outputFile.open(QIODevice::ReadOnly)) {
QByteArray goodData = outputFile.readAll().mid(0, goodSize);
outputFile.close();
if (outputFile.open(QIODevice::WriteOnly)) {
outputFile.write(goodData);
outputFile.close();
QMutexLocker lock(&mutex);
already = goodSize;
}
}
}
} else {
QMutexLocker lock(&mutex);
already = goodSize;
}
}
if (!already) {
QFile::remove(fileName);
}
}
}
示例3: getAllIncludes
void getAllIncludes(QString path, QFileInfoList h_files, QFileInfoList cpp_files, QStringList& includes)
{
for(QFileInfoList::iterator it = h_files.begin(); it != h_files.end(); it++)
{
QFile file(it->absoluteFilePath());
if(file.open(QFile::ReadOnly))
{
QTextStream textStream(&file);
while(!textStream.atEnd())
{
QString line = textStream.readLine();
if( line.indexOf("#include ") != -1 && line.indexOf("Q") != -1 )
{
addToStringList(includes, line);
}
}
file.close();
}
}
for(QFileInfoList::iterator it = cpp_files.begin(); it != cpp_files.end(); it++)
{
QFile file(it->absoluteFilePath());
if(file.open(QFile::ReadOnly))
{
QTextStream textStream(&file);
while(!textStream.atEnd())
{
QString line = textStream.readLine();
if( line.indexOf("//") == -1 &&
line.indexOf("#include ") != -1 &&
line.indexOf("Q") != -1
)
{
addToStringList(includes, line);
}
}
file.close();
}
}
}
示例4: 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();
}
示例5: RenamePak
/**********
*返回值:0成功
*1原包名不存在
*2创建包出错
*3目的包名已经存在
*4替换包名过程出错
***********/
int PathManager::RenamePak(QString &path, QString &oldPakName, QString &newPakName)
{
QString oldName = oldPakName;
QString newName = newPakName;
oldName.replace(".", "/");
newName.replace(".", "/");
QString srcDir = path + "/" + oldName;
QString destDir = path + "/" + newName;
QDir dirSrc(srcDir);
QDir dirDest(destDir);
if (!dirSrc.exists()){
return 1;
}
dirSrc.setFilter(QDir::NoDotAndDotDot | QDir::Files);
QFileInfoList allFiles = dirSrc.entryInfoList();
if (allFiles.isEmpty()){
return 1;
}
if (!dirDest.exists() && !dirDest.mkpath(destDir)){
return 2;
}
dirDest.setFilter(QDir::NoDotAndDotDot | QDir::Files);
if (!dirDest.entryInfoList().isEmpty()){
return 3;
}
for (QFileInfoList::iterator ite = allFiles.begin(); ite != allFiles.end(); ite++){
QString tmpName = ite->absoluteFilePath();
tmpName = tmpName.mid(tmpName.lastIndexOf("/") + 1);
if (!dirDest.exists()){
if (dirDest.mkpath(destDir)){
return 4;
}
}
if (!CopyFile(ite->absoluteFilePath(), destDir + "/" + tmpName, true) || !QFile::remove(ite->absoluteFilePath())){
return 4;
}
}
RemoveEmptyDirFromDeepest(srcDir);
return 0;
}
示例6: cleanup
void KTNEFMain::cleanup()
{
QDir d( KGlobal::dirs()->localkdedir() + "/share/apps/ktnef/tmp/" );
QFileInfoList list = d.entryInfoList( QDir::Files | QDir::Hidden, QDir::Unsorted );
QFileInfoList::iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
d.remove( it->absoluteFilePath() );
}
}
示例7: appendAllFileNamesForFileType
void MdPlottingCmapsProvider::appendAllFileNamesForFileType(
QStringList &colorMapNames, QStringList &colorMapFiles,
QString colorMapDirectory, QString fileType) {
QDir directory(colorMapDirectory);
QStringList filter(QString("*.%1").arg(fileType));
QFileInfoList info = directory.entryInfoList(filter, QDir::Files);
for (QFileInfoList::iterator it = info.begin(); it != info.end(); ++it) {
colorMapNames.append(it->baseName());
colorMapFiles.append(it->absoluteFilePath());
}
}
示例8: RemoveDir
bool PathManager::RemoveDir(const QString &dirName)
{
QVector<QString> dirNames;
QDir dir(dirName);
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->absoluteFilePath())){
return false;
}
}
curFi++;
}//end of while
}
}
//删除文件夹
for (int i = dirNames.size() - 1; i >= 0; --i)
{
dir.setPath(dirNames[i]);
if (!dir.rmdir(".")){
return false;
}
}
return true;
}
示例9: 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);
}
}
}
示例10: featuresCount
int UBFeaturesComputingThread::featuresCount(const QUrl &pPath)
{
int noItems = 0;
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(pPath.toLocalFile());
QFileInfoList::iterator fileInfo;
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
QString fullFileName = fileInfo->absoluteFilePath();
UBFeatureElementType featureType = UBFeaturesController::fileTypeFromUrl(fullFileName);
if (featureType != FEATURE_INVALID && !fullFileName.contains(".thumbnail.")) {
noItems++;
}
if (featureType == FEATURE_FOLDER) {
noItems += featuresCount(QUrl::fromLocalFile(fullFileName));
}
}
return noItems;
}
示例11: findIconFiles
QStringList BitmapFactoryInst::findIconFiles() const
{
QStringList files, filters;
QList<QByteArray> formats = QImageReader::supportedImageFormats();
for (QList<QByteArray>::iterator it = formats.begin(); it != formats.end(); ++it)
filters << QString::fromAscii("*.%1").arg(QString::fromAscii(*it).toLower());
QStringList paths = d->paths;
#if QT_VERSION >= 0x040500
paths.removeDuplicates();
#endif
for (QStringList::ConstIterator pt = paths.begin(); pt != paths.end(); ++pt) {
QDir d(*pt);
d.setNameFilters(filters);
QFileInfoList fi = d.entryInfoList();
for (QFileInfoList::iterator it = fi.begin(); it != fi.end(); ++it)
files << it->absoluteFilePath();
}
#if QT_VERSION >= 0x040500
files.removeDuplicates();
#endif
return files;
}
示例12: QGridLayout
QFrame *TimeLapseWidget::tlConstruct(QWidget *, QSettings *qs) {
QCCamera::initCamLibrary();
// Initialize GUI stuff
QGridLayout *layout = new QGridLayout();
layout->addWidget(new QLabel("Available Cameras"),0,0,1,1);
attachedCameras = new QComboBox;
populateCameraList();
layout->addWidget(attachedCameras, 0,1,1,2);
layout->addWidget(new QLabel("Output directory"),1,0,1,1);
saveDirectory = new QLineEdit();
layout->addWidget( saveDirectory,1,1,1,1 );
QCompleter *completer = new QCompleter(this);
completer->setModel(new QDirModel(completer));
saveDirectory->setCompleter(completer);
directoryButton = new QPushButton( tr("Browse...") );
layout->addWidget( directoryButton,1,2,1,1 );
intervalBox = new QSpinBox;
intervalBox->setMinimum(1);
intervalBox->setMaximum(99999);
lengthOfTimeBox = new QTimeEdit( QTime(0, 0, 0, 0), this );
lengthOfTimeBox->setDisplayFormat( "HH:mm:ss" );
layout->addWidget(new QLabel( "Interval" ), 2,0);
layout->addWidget(intervalBox, 2,1);
seconds = new QRadioButton( "S" );
seconds->setChecked( true );
minutes = new QRadioButton( "M" );
layout->addWidget( seconds, 2, 2, 1, 1, Qt::AlignLeft );
layout->addWidget( minutes, 2, 2, 1, 1, Qt::AlignRight );
layout->addWidget(new QLabel("Time to run"), 3,0);
layout->addWidget( lengthOfTimeBox, 3,1);
startButton = new QPushButton(QIcon(":/images/play.svgz"), "Start");
stopButton = new QPushButton(QIcon(":/images/stop.svgz"), "Stop");
layout->addWidget(startButton, 4,0);
layout->addWidget(stopButton, 4,1);
intervalBox->setFocus();
setupConnections();
startButton->setDisabled( false );
stopButton->setDisabled( true );
saveDirectory->setText(".");
qs->beginGroup("TimeLapseTab");
intervalBox->setValue(qs->value("intervalBox", 15).toInt());
lengthOfTimeBox->setTime(qs->value("lengthOfTimeBox", QTime(0,0,0,0)).toTime());
saveDirectory->setText(qs->value("saveDirectory", ".").toString());
seconds->setChecked(qs->value("seconds", true).toBool());
minutes->setChecked(qs->value("minutes", false).toBool());
qs->endGroup();
saveDirectoryUpdated();
#ifndef CANON_SDK_BUILD
camFinder = new QFileSystemWatcher(this);
QFileInfoList dirs = QDir("/dev/bus/usb/").entryInfoList();
for (QFileInfoList::iterator iter = dirs.begin();
iter != dirs.end();
++iter) {
camFinder->addPath(iter->absoluteFilePath());
}
connect(camFinder, SIGNAL(directoryChanged(QString)),
this, SLOT(populateCameraList()));
#endif
QFrame *rv = new QFrame;
rv->setLayout(layout);
return rv;
}
示例13: prepare
int prepare(QFileInfo f, QStringList paths) {
if (paths.isEmpty()) {
cout << "No -path args were passed :(\n";
return -1;
}
int lastVersion = 0;
QString lastVersionStr;
QFileInfo last;
QFileInfoList l = f.absoluteDir().entryInfoList(QDir::Files);
for (QFileInfoList::iterator i = l.begin(), e = l.end(); i != e; ++i) {
QRegularExpressionMatch m = QRegularExpression("/tsetup.((\\d+).(\\d+).(\\d+)).exe$").match(i->absoluteFilePath());
if (!m.hasMatch()) continue;
int version = m.captured(2).toInt() * 1000000 + m.captured(3).toInt() * 1000 + m.captured(4).toInt();
if (version > lastVersion) {
lastVersion = version;
lastVersionStr = m.captured(1);
last = *i;
}
}
if (!lastVersion) {
cout << "No tsetup.X.Y.Z.exe found :(\n";
return -1;
}
cout << "Last version: " << lastVersionStr.toUtf8().constData() << " (" << lastVersion << "), executing packer..\n";
QDir dir("deploy/" + lastVersionStr);
if (dir.exists()) {
cout << "Version " << lastVersionStr.toUtf8().constData() << " already exists in /deploy..\n";
return -1;
}
QString packer = QString("Packer.exe -version %1").arg(lastVersion);
for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) {
packer += " -path " + *i;
}
int res = system(packer.toUtf8().constData());
if (res) return res;
dir.mkpath(".");
paths.push_back("Telegram.pdb");
paths.push_back("Updater.pdb");
paths.push_back("tsetup." + lastVersionStr + ".exe");
paths.push_back(QString("tupdate%1").arg(lastVersion));
for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) {
if (!QFile::copy(*i, "deploy/" + lastVersionStr + "/" + *i)) {
cout << "Could not copy " << i->toUtf8().constData() << " to deploy/" << lastVersionStr.toUtf8().constData() << "\n";
return -1;
}
cout << "Copied " << i->toUtf8().constData() << "..\n";
}
for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) {
QFile::remove(*i);
}
cout << "Update created in deploy/" << lastVersionStr.toUtf8().constData() << "\n";
return 0;
}
示例14: CopyDir
bool PathManager::CopyDir(const QString &source, const QString &destination, bool isCover)
{
/* 递归实现 */
/*QDir directory(source);
if (!directory.exists()){
return false;
}
QString srcPath = QDir::toNativeSeparators(source);
if (!srcPath.endsWith(QDir::separator())){
srcPath += QDir::separator();
}
QString dstPath = QDir::toNativeSeparators(destination);
if (!dstPath.endsWith(QDir::separator())){
dstPath += QDir::separator();
}
QStringList fileNames = directory.entryList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden);
for (QStringList::size_type i = 0; i != fileNames.size(); ++i)
{
QString fileName = fileNames.at(i);
QString srcFilePath = srcPath + fileName;
QString dstFilePath = dstPath + fileName;
QFileInfo fileInfo(srcFilePath);
if (fileInfo.isFile() || fileInfo.isSymLink()){
if (isCover){
QFile::setPermissions(dstFilePath, QFile::WriteOwner);
}
if (!QFile::copy(srcFilePath, dstFilePath)){
return false;
}
}
else if (fileInfo.isDir()){
QDir dstDir(dstFilePath);
dstDir.mkpath(dstFilePath);
if (!CopyDir(srcFilePath, dstFilePath, isCover)){
return false;
}
}
}
return true;*/
QVector<QString> dirNames;
QVector<QString> fileNames;
QDir dir(source);
if (!dir.exists()){
return false;
}
dirNames.clear();
dirNames << source;
QFileInfoList filst;
QFileInfoList::iterator curFi;
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())
{
if (curFi->isDir()){
dirNames.push_back(curFi->filePath());
}
else if (curFi->isFile()){
fileNames.push_back(curFi->absoluteFilePath());
}
curFi++;
}
}
}
for (QVector<QString>::Iterator ite = dirNames.begin(); ite != dirNames.end(); ite++)
{
QDir dirSrc(source);
QDir dirDest(destination);
ite->replace(dirSrc.absolutePath(), dirDest.absolutePath());
QDir dirTmp(*ite);
if (!dirTmp.exists() && !dirTmp.mkpath(*ite)){
return false;
}
}
for (QVector<QString>::Iterator ite = fileNames.begin(); ite != fileNames.end(); ite++)
{
QDir dirSrc(source);
QDir dirDest(destination);
QString srcPath = *ite;
QString tar = ite->replace(dirSrc.absolutePath(), dirDest.absolutePath());
QFile file(tar);
if (file.exists()){
if (isCover){
if (!file.remove()){
return false;
//.........这里部分代码省略.........
示例15: ReplaceAppPakInSrc
/**********
*返回值:0成功
*1原包名不存在
*2创建包出错
*3目的包名已经存在
*4替换包名过程出错
*5替换app包名出错
***********/
int PathManager::ReplaceAppPakInSrc(QString &path, QString &oldName, QString &newName)
{
QVector<QString> dirNames;
QDir dir(path);
QFileInfoList filst;
QFileInfoList::iterator curFi;
//初始化
dirNames.clear();
if (dir.exists()){
dirNames << path;
}
else{
return 0;
}
bool isTopDir = 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 (isTopDir){
isTopDir = false;
for (int i = 0; i < filst.size(); i++)
{
if (filst[i].fileName() == "assets" || filst[i].fileName() == "bin" || filst[i].fileName() == "libs"){
filst.removeAt(i);
i--;
}
}
}
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->absoluteFilePath().toLower().endsWith(".java")){
if (!ReplaceAppPakNameInJava(path, curFi->absoluteFilePath(), oldName, newName)){
return 1;
}
}
else if (curFi->absoluteFilePath().toLower().endsWith(".xml")){
if (!ReplaceAppPakNameInXml(path, curFi->absoluteFilePath(), oldName, newName)){
return 1;
}
}
}
curFi++;
}//end of while
}
}
if (!ReplaceAppPakNameInManifest(path, oldName, newName)){
return 5;
}
return 0;
}