Example #1
0
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;
}
Example #2
0
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;
}
Example #3
0
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;
}
Example #4
0
	bool ViewFileManager::addUserFileThrow(const string& aFileName, int64_t aSize, const TTHValue& aTTH, const HintedUser& aUser, bool aIsText) throw(QueueException, FileException) {
		if (aUser == ClientManager::getInstance()->getMe()) {
			auto paths = ShareManager::getInstance()->getRealPaths(aTTH);
			if (!paths.empty()) {
				return addLocalFile(paths.front(), aTTH, aIsText);
			}

			return false;
		}

		if (getFile(aTTH)) {
			return false;
		}

		QueueManager::getInstance()->addOpenedItem(aFileName, aSize, aTTH, aUser, true, aIsText);
		return true;
	}
Example #5
0
	ViewFilePtr ViewFileManager::addUserFileThrow(const string& aFileName, int64_t aSize, const TTHValue& aTTH, const HintedUser& aUser, bool aIsText) {
		if (ShareManager::getInstance()->isFileShared(aTTH)) {
			return addLocalFile(aTTH, aIsText);
		}

		if (aUser == ClientManager::getInstance()->getMe()) {
			return nullptr;
		}

		if (getFile(aTTH)) {
			return nullptr;
		}

		auto qi = QueueManager::getInstance()->addOpenedItem(aFileName, aSize, aTTH, aUser, true, aIsText);

		auto file = createFile(qi->getTarget(), qi->getTTH(), aIsText, false);
		if (file) {
			file->onAddedQueue(qi->getTarget(), qi->getSize());
		}

		return file;
	}