QStringList KoStore::addLocalDirectory( const QString &dirPath, const QString &destName ) { QString dot = "."; QString dotdot = ".."; QStringList content; QDir dir(dirPath); if ( !dir.exists() ) return 0; QStringList files = dir.entryList(); for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it ) { if ( *it != dot && *it != dotdot ) { QString currentFile = dirPath + "/" + *it; QString dest = destName.isEmpty() ? *it : (destName + "/" + *it); QFileInfo fi ( currentFile ); if ( fi.isFile() ) { addLocalFile ( currentFile, dest ); content.append(dest); } else if ( fi.isDir() ) { content += addLocalDirectory ( currentFile, dest ); } } } return content; }
bool KArchive::addLocalDirectory( const QString& path, const QString& destName ) { QDir dir( path ); if ( !dir.exists() ) return false; dir.setFilter(dir.filter() | QDir::Hidden); const QStringList files = dir.entryList(); for ( QStringList::ConstIterator it = files.begin(); it != files.end(); ++it ) { if ( *it != "." && *it != ".." ) { QString fileName = path + '/' + *it; // qDebug() << "storing " << fileName; QString dest = destName.isEmpty() ? *it : (destName + '/' + *it); QFileInfo fileInfo( fileName ); if ( fileInfo.isFile() || fileInfo.isSymLink() ) addLocalFile( fileName, dest ); else if ( fileInfo.isDir() ) addLocalDirectory( fileName, dest ); // We omit sockets } } return true; }
bool KArchive::addLocalDirectory(const QString &path, const QString &destName) { QDir dir(path); if (!dir.exists()) { setErrorString( tr("Directory %1 does not exist") .arg(path)); return false; } dir.setFilter(dir.filter() | QDir::Hidden); const QStringList files = dir.entryList(); for (QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) { if (*it != QLatin1String(".") && *it != QLatin1String("..")) { QString fileName = path + QLatin1Char('/') + *it; // qCDebug(KArchiveLog) << "storing " << fileName; QString dest = destName.isEmpty() ? *it : (destName + QLatin1Char('/') + *it); QFileInfo fileInfo(fileName); if (fileInfo.isFile() || fileInfo.isSymLink()) { addLocalFile(fileName, dest); } else if (fileInfo.isDir()) { addLocalDirectory(fileName, dest); } // We omit sockets } } return true; }