Beispiel #1
0
FileWatcher::FileWatcher(QString dir, ScanType type, qint32 notebookLid, bool subdirs, QObject *parent) :
    QFileSystemWatcher(parent)
{
    this->notebookLid = notebookLid;
    this->dir = dir;
    this->scanType = type;
    this->includeSubdirectories = subdirs;
    addDirectory(dir);

    connect(this, SIGNAL(directoryChanged(QString)), this, SLOT(saveDirectory(QString)));
    connect(this, SIGNAL(fileChanged(QString)), this, SLOT(saveFile(QString)));
}
Beispiel #2
0
FileList *FileSystem::findFilesMatchingExtension(char *folder, char *extension) {
    FileList *fileList = new FileList;
    if (fileList == NULL) {
        Serial.println("Can not allocate RAM");
        return fileList;
    }

    fileList->parentFolder = folder;
    fileList->size = 0;
    fileList->currentIndex = 0;

    File root = SD.open(folder);
    saveDirectory(fileList, root, 0, extension);
    return fileList;
}
void MainWindow::openProject(const QString &dir){
    basePath = dir + '/';
    SpecificElabPath = dir + "/EL/SpecificElaborations/";
    QString ConfigPath = dir + "/EL/Configs/";
    resize(WIND_WIDTH, WIND_HEIGHT);

    //======================================= Test Subdirectories
    if(!QDir(SpecificElabPath).exists() || !QDir(ConfigPath).exists()){
        QString message = tr("Project does not contain the directory /EL/SpecificElaborations/ or /EL/Configs/");
        ui->tabWidget->setVisible(false);
        ui->elaborateButton->setHidden(true);
        statusBar()->showMessage(message);
        return;
    }

    //======================================= Check if it contains at least one TopLevel
    QDirIterator directories(ConfigPath, QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::NoIteratorFlags);
    QString subpath;

    if(!directories.hasNext()){
        ui->tabWidget->setVisible(false);
        ui->elaborateButton->setHidden(true);
        QString message = tr("Project has no folder inside /EL/Configs/");
        statusBar()->showMessage(message);
        return;
    }

    //======================================= Check if it contains >1 TopLevel
    subpath = directories.next(); //next folder
    if(directories.hasNext()){
        ui->treeView_configs->setRootIndex(dirModel_confs->index(ConfigPath));//>1 TopLevel (error?)
    }
    else
        ui->treeView_configs->setRootIndex(dirModel_confs->index(subpath));//Has 1 TopLevel (go inside)

    ui->treeView_elaborations->setRootIndex(dirModel_elabs->index(SpecificElabPath));

    ui->tabWidget->setVisible(true);
    ui->treeView_elaborations->setVisible(true);

    ui->elaborateButton->setHidden(false);
    QString message = tr("Project Loaded Successfully!");
    resize(WIND_WIDTH, WIND_HEIGHT2);
    statusBar()->showMessage(message);
    //ui->treeView->setCurrentIndex(dirModel->index(directoryRoot));
    saveDirectory(dir);
}
Beispiel #4
0
/*
 * Save one file into the tar file.
 * If the file is a directory, then this will recursively save all of
 * the files and directories within the directory.  The seeLinks
 * flag indicates whether or not we want to see symbolic links as
 * they really are, instead of blindly following them.
 */
static void
saveFile(const char * fileName, BOOL seeLinks)
{
	int		status;
	int		mode;
	struct stat	statbuf;

	if (verboseFlag)
		printf("a %s\n", fileName);

	/*
	 * Check that the file name will fit in the header.
	 */
	if (strlen(fileName) >= TAR_NAME_SIZE)
	{
		fprintf(stderr, "%s: File name is too long\n", fileName);

		return;
	}

	/*
	 * Find out about the file.
	 */
#ifdef	S_ISLNK
	if (seeLinks)
		status = lstat(fileName, &statbuf);
	else
#endif
		status = stat(fileName, &statbuf);

	if (status < 0)
	{
		perror(fileName);

		return;
	}

	/*
	 * Make sure we aren't trying to save our file into itself.
	 */
	if ((statbuf.st_dev == tarDev) && (statbuf.st_ino == tarInode))
	{
		fprintf(stderr, "Skipping saving of archive file itself\n");

		return;
	}

	/*
	 * Check the type of file.
	 */
	mode = statbuf.st_mode;

	if (S_ISDIR(mode))
	{
		saveDirectory(fileName, &statbuf);

		return;
	}

	if (S_ISREG(mode))
	{
		saveRegularFile(fileName, &statbuf);

		return;
	}

	/*
	 * The file is a strange type of file, ignore it.
	 */
	fprintf(stderr, "%s: not a directory or regular file\n", fileName);
}