void FilesCnr::getFiles()
{
 PFILEFINDBUF3 pffb = NULL;
 OString       FileSpec(scanDirectory);
 ULONG         bufSize = sizeof(FILEFINDBUF3) * 200;
 HDIR          hdir = HDIR_CREATE;
 ULONG         ulMaxFiles = 200;
 APIRET        rc;

 freeItems();
 FileList.reset();

 DosAllocMem((PPVOID)&pffb, bufSize, PAG_READ | PAG_WRITE | PAG_COMMIT);

 if (!pffb)
   return;

 FileSpec + "\\*";

 DosError(FERR_DISABLEHARDERR);
 rc = DosFindFirst(FileSpec.text, &hdir, 
                   FILE_NORMAL | FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
                   pffb, bufSize, &ulMaxFiles, FIL_STANDARD);

 while(!rc) {
   insertFiles(pffb, ulMaxFiles);
   rc = DosFindNext(hdir, pffb, bufSize, &ulMaxFiles); }

 DosFindClose(hdir);
 DosError(FERR_ENABLEHARDERR);
 DosFreeMem(pffb);
}
Exemple #2
0
void FileList::update(const RevFile* files, bool newFiles) {

	QPalette pl = QApplication::palette();
	if (!st->diffToSha().isEmpty())
		pl.setColor(QPalette::Base, QGit::LIGHT_BLUE);

	setPalette(pl);
	if (newFiles)
		insertFiles(files);

	QString fileName(currentText());
	git->removeExtraFileInfo(&fileName); // could be a renamed/copied file

	if (!fileName.isEmpty() && (fileName == st->fileName())) {
		currentItem()->setSelected(st->selectItem()); // just a refresh
		return;
	}
	clearSelection();

	if (st->fileName().isEmpty())
		return;

	QList<QListWidgetItem*> l = findItems(st->fileName(), Qt::MatchExactly);
	if (l.isEmpty()) { // could be a renamed/copied file, try harder

		fileName = st->fileName();
		git->addExtraFileInfo(&fileName, st->sha(), st->diffToSha(), st->allMergeFiles());
		l = findItems(fileName, Qt::MatchExactly);
	}
	if (!l.isEmpty()) {
		setCurrentItem(l.first());
		l.first()->setSelected(st->selectItem());
	}
}
Exemple #3
0
int readMp3FilesToTree(FileTree* ftree, const char* path_source)
{
  int i = 0;
  int res = 0;
  int folder_counter = 1;             // total amount of subfolders found
  int nfiles = 0;                    // number of files found
  int nfolders = 0;                 //  number of subfolders found
  int length_sfolder = MAX_ARRAY; 
  
  cupath*    sfolder = NULL;
  cupath     path_storage[MAX_FILES];  
  mp3        mp3_data[MAX_FILES];

  
  memset(mp3_data, 0, sizeof(mp3)*MAX_FILES);  

  if(NULL == (sfolder = (cupath*)(calloc(length_sfolder, sizeof(cupath)))))
  {
    perror("failed to allocate data");
    return -10;
  }
  

   strcpy(sfolder[i].fpath, path_source);
  
    for(i = 0; i < folder_counter; ++i)
    {
    res = readFilesInsideDir(sfolder[i].fpath, mp3_data, &nfiles, path_storage, &nfolders);
    if(res != 0)
      break; 
    
    insertFiles(ftree, mp3_data, nfiles);  

    sfolder = copyToArrayFolder(sfolder, &length_sfolder, path_storage, nfolders, &folder_counter);
    }

    
free (sfolder);
return res;
}
Exemple #4
0
/*!
    Takes the \a helpData and generates a new documentation
    set from it. The Qt compressed help file is written to \a
    outputFileName. Returns true on success, otherwise false.
*/
bool QHelpGenerator::generate(QHelpDataInterface *helpData,
                              const QString &outputFileName)
{
    emit progressChanged(0);
    d->error.clear();
    if (!helpData || helpData->namespaceName().isEmpty()) {
        d->error = tr("Invalid help data!");
        return false;
    }

    QString outFileName = outputFileName;
    if (outFileName.isEmpty()) {
        d->error = tr("No output file name specified!");
        return false;
    }

    QFileInfo fi(outFileName);
    if (fi.exists()) {
        if (!fi.dir().remove(fi.fileName())) {
            d->error = tr("The file %1 cannot be overwritten!").arg(outFileName);
            return false;
        }
    }

    setupProgress(helpData);

    emit statusChanged(tr("Building up file structure..."));
    bool openingOk = true;
    {
        QSqlDatabase db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), QLatin1String("builder"));
        db.setDatabaseName(outFileName);
        openingOk = db.open();
        if (openingOk)
            d->query = new QSqlQuery(db);
    }

    if (!openingOk) {
        d->error = tr("Cannot open data base file %1!").arg(outFileName);
        cleanupDB();
        return false;
    }

    d->query->exec(QLatin1String("PRAGMA synchronous=OFF"));
    d->query->exec(QLatin1String("PRAGMA cache_size=3000"));

    addProgress(1.0);
    createTables();
    insertFileNotFoundFile();
    insertMetaData(helpData->metaData());

    if (!registerVirtualFolder(helpData->virtualFolder(), helpData->namespaceName())) {
        d->error = tr("Cannot register namespace %1!").arg(helpData->namespaceName());
        cleanupDB();
        return false;
    }
    addProgress(1.0);

    emit statusChanged(tr("Insert custom filters..."));
    foreach (const QHelpDataCustomFilter &f, helpData->customFilters()) {
        if (!registerCustomFilter(f.name, f.filterAttributes, true)) {
            cleanupDB();
            return false;
        }
    }
    addProgress(1.0);

    int i = 1;
    QList<QHelpDataFilterSection>::const_iterator it = helpData->filterSections().constBegin();
    while (it != helpData->filterSections().constEnd()) {
        emit statusChanged(tr("Insert help data for filter section (%1 of %2)...")
            .arg(i++).arg(helpData->filterSections().count()));
        insertFilterAttributes((*it).filterAttributes());
        QByteArray ba;
        QDataStream s(&ba, QIODevice::WriteOnly);
        foreach (QHelpDataContentItem *itm, (*it).contents())
            writeTree(s, itm, 0);
        if (!insertFiles((*it).files(), helpData->rootPath(), (*it).filterAttributes())
            || !insertContents(ba, (*it).filterAttributes())
            || !insertKeywords((*it).indices(), (*it).filterAttributes())) {
            cleanupDB();
            return false;
        }
        ++it;
    }

    cleanupDB();
    emit progressChanged(100);
    emit statusChanged(tr("Documentation successfully generated."));
    return true;
}
void FolderModel::listFolderContents(const File &file)
{
    Error error;
    File folder = file;

    // Enumerate folder contents
    FileEnumerator fileEnumerator = folder.enumerateChildren(
        "*", File::QueryInfoNorm, error);
    if (error.hasError()) {
        qWarning("Couldn't enumerate %s: %s",
                 qPrintable(folder.getUri().toString(QUrl::FullyEncoded)),
                 qPrintable(error.getMessage()));
        return;
    }

    // Save FileInfo objects
    QList<FileInfo> fileInfoList;
    for (;;) {
        FileInfo fileInfo = fileEnumerator.nextFile(error);
        if (error.hasError()) {
            qWarning("Couldn't advance enumerator %s: %s",
                     qPrintable(folder.getUri().toString(QUrl::FullyEncoded)),
                     qPrintable(error.getMessage()));
            return;
        }

        if (fileInfo.isNull())
            break;

        fileInfoList.append(fileInfo);
    }

    // Close enumerator
    fileEnumerator.close(error);
    if (error.hasError()) {
        qWarning("Couldn't close enumerator on %s: %s",
                 qPrintable(folder.getUri().toString(QUrl::FullyEncoded)),
                 qPrintable(error.getMessage()));
        return;
    }

    // Populate model
    removeAll();
    insertFiles(fileInfoList);

#if 0
    m_folderMonitor = new FileMonitor(folder.monitorDirectory(folder.MonitorNorm, error, 0));
    if (error.hasError()) {
        qWarning("Failed to monitor %s: %s",
                 qPrintable(folder.getUri().toString(QUrl::FullyEncoded)),
                 qPrintable(error.getMessage()));
        return;
    }

    connect(m_folderMonitor, SIGNAL(changed(FileMonitor *, File, File, FileMonitorEvent)),
            this, SLOT(changed(FileMonitor *, File, File, FileMonitor::FileMonitorEvent)));
#endif

    // Change URI
    m_uri = folder.getUri();
    emit folderChanged();
}