Ejemplo n.º 1
0
Archivo: rom.c Proyecto: mrzzzrm/mooboy
static void change_dir() {
    save_selected_element();

    strcpy(&cwd[strlen(cwd)], direntries[list->selected]->name);
    save_dir();
    poll_dir();
}
Ejemplo n.º 2
0
bool Replay::load(){
    data.clear();
    std::string file_to_load;

    if(ptr_record->get_last_saved_file() == ""){
        ROS_INFO("record_folder: %s",record_folder.c_str());
        boost::filesystem::path save_dir(record_folder);
        boost::filesystem::directory_iterator end_iter;

        if (boost::filesystem::exists(save_dir) && boost::filesystem::is_directory(save_dir)){
            for( boost::filesystem::directory_iterator dir_iter(save_dir) ; dir_iter != end_iter ; ++dir_iter){
                if (boost::filesystem::is_regular_file(dir_iter->status()) ){
                    file_to_load = (*dir_iter).path().string();
                    break;
                }
            }
        }
    }else{
        file_to_load = ptr_record->get_last_saved_file();
    }


    std::ifstream file(file_to_load, std::ios_base::in);
    if(file.is_open()){

        ROS_INFO("loading: %s",boost::filesystem::path(file_to_load).stem().string().c_str());

        while (!file.eof()){
            file >> data_t.x >> data_t.y >> data_t.z >> data_t.roll >> data_t.pitch >> data_t.yaw;
            data.push_back(data_t);
        }
        file.close();
       // ROS_INFO("number samples ===> %d",data.size());
        return true;
    }else{
Ejemplo n.º 3
0
void add_file_to_dir(char *file, int start_sector) {
		if(does_file_exist_in_dir(file) != -1) {
			printf("File already exists\n");
		}else { 
			strcpy(dir[dircnt],file);
			fsect[dircnt] = start_sector;
			dircnt++;
			}
	save_dir();
}
Ejemplo n.º 4
0
void read_dir(void) {
	int i = 0;
	while(fgets(line,sizeof line,fdir)!=NULL) {
		sscanf(line,"%s %d",dir[i], &fsect[i]);
	
		i++;
	}
	dircnt = i;
	save_dir();
}
Ejemplo n.º 5
0
void delete_file_from_dir(int position) {
	int i = 0, j = 1;
	for(i = 0; i < dircnt; i++) {
		strcpy(dir[position], dir[position + 1]);
		fsect[position] = fsect[position + 1];
		position++;
		j++;
		
	}
	dircnt --;
	save_dir();
}
Ejemplo n.º 6
0
Archivo: rom.c Proyecto: mrzzzrm/mooboy
static void parent_dir() {
    int c;
    save_selected_element();
    for(c = (int)strlen(cwd) - 2; c >=0 && cwd[c] != '/'; c--) {
    }
    if(c <= 0) {
        sprintf(cwd, "/");
    }
    else {
        cwd[c+1] = '\0';
    }
    save_dir();
    if(!poll_dir()) {
        to_base_dir();
    }
}
    bool save(ColorPalette& palette, const QString& suggested_filename = QString())
    {
        // Attempt to save with the existing file names
        if ( !suggested_filename.isEmpty() && attemptSave(palette, suggested_filename) )
            return true;
        if ( attemptSave(palette, palette.fileName()) )
            return true;

        // Set up the save directory
        QDir save_dir(save_path);
        if ( !save_dir.exists() && !QDir().mkdir(save_path) )
            return false;

        // Attempt to save as (Name).gpl
        QString filename = palette.name()+".gpl";
        if ( !save_dir.exists(filename) &&
                attemptSave(palette, save_dir.absoluteFilePath(filename)) )
            return true;

        // Get all of the files matching the pattern *.gpl
        save_dir.setNameFilters(QStringList() << "*.gpl");
        save_dir.setFilter(QDir::Files);
        QStringList existing_files = save_dir.entryList();

        // For all the files that match (Name)(Number).gpl, find the maximum (Number)
        QRegularExpression name_regex(QRegularExpression::escape(palette.name())+"([0-9]+)\\.gpl");
        int max = 0;
        for ( const auto& existing_file : existing_files )
        {
            QRegularExpressionMatch match = name_regex.match(existing_file);
            if ( match.hasMatch() )
            {
                int num = match.captured(1).toInt();
                if ( num > max )
                    max = num;
            }
        }

        return attemptSave(palette,
            save_dir.absoluteFilePath(QString("%1%2.gpl").arg(palette.name()).arg(max+1))
        );
    }