Ejemplo n.º 1
0
static void game_list_init_nocache(void)
{
	int i, indx;
	FILE *f;

	extern char **rompathv;
	extern int rompathc;

	//SQ: read the favorites
	favorites_read();

    for( indx = 0; indx < rompathc ; ++indx )
    {
        const char *dir_name = rompathv[indx];

		//sq DIR *d=opendir("roms");
		DIR *d=opendir(dir_name);
		char game[32];
		if (d)
		{
			struct dirent *actual=readdir(d);
			while(actual)
			{
				for (i=0;i<NUMGAMES;i++)
				{
					if (fe_drivers[i].available==0)
					{
						sprintf(game,"%s.zip",fe_drivers[i].name);
						if (strcmp(actual->d_name,game)==0)
						{
							fe_drivers[i].available=1;
							game_num_avail++;
							break;
						}
					}
				}
				actual=readdir(d);
			}
			closedir(d);
		}
	}
	
	if (game_num_avail)
	{
		remove("frontend/mame.lst");
		sync();
		f=fopen("frontend/mame.lst","w");
		if (f)
		{
			for (i=0;i<NUMGAMES;i++)
			{
				fputc(fe_drivers[i].available,f);
			}
			fclose(f);
			sync();
		}
	}
}
Ejemplo n.º 2
0
static void favorites_add(char *game)
{
    //SQ:Add the game to the favorites file
    FILE *file;

    //SQ:Make sure the directory exists before creating a new file
    mkdir("folders", 0777);

    file = fopen("folders/Favorites.ini", "a");
    if (file != NULL) {
        fputs(game, file);
        fputc('\n', file);
        fclose(file);
    }

    //SQ:All done so re-read the favorites array
    favorites_read();
}
Ejemplo n.º 3
0
static void favorites_remove(char *game) 
{
    //SQ: Scan through the favorites file and remove
    //the requested line, creating a new file.
    FILE *file, *file2;
    char filename[1024], filename2[1024];
    int counter=0;
    int startread=0;

    sprintf(filename,get_documents_path("folders/Favorites.ini"));
    sprintf(filename2, "%s.new", filename);
    
    file = fopen (filename, "r");
    file2 = fopen (filename2, "w");
    if ( file != NULL && file2 != NULL) {
        char line[256]; 
        char line2[256];
        
        while ( fgets(line, sizeof line, file) != NULL ) { /* read a line */
            strcpy(line2, line);
            
            if (line[strlen(line) - 1] == '\n') line[strlen(line) - 1] = '\0';
            if (line[strlen(line) - 1] == '\r') line[strlen(line) - 1] = '\0';
            
            if (line[0] != '[' && line[0] != '\0' && strlen(line) <= 8) {
                if (strcmp(line, game) == 0) {
                    continue;
                }                     
            }
            fputs(line2, file2); 
            
        }
        fclose (file);
        fclose (file2);
        
        //Move the new file over the old one.
        rename(filename2, filename);
    }
    
    //SQ:All done so re-read the favorites array
    favorites_read();
} 
Ejemplo n.º 4
0
static void favorites_add(char *game) 
{
    //SQ:Add the game to the favorites file
    FILE *file;
    char filename[1024];
    
    //SQ:Make sure the directory exists before creating a new file
    mkdir(get_documents_path("folders"), 0777);
    
    sprintf(filename,get_documents_path("folders/Favorites.ini"));
    file = fopen(filename, "a");
    if (file != NULL) {
        fputs(game, file);
        fputc('\n', file);
        fclose(file);
    }
    
    //SQ:All done so re-read the favorites array
    favorites_read();
}
Ejemplo n.º 5
0
static void game_list_init_cache(void)
{
	FILE *f;
	int i;

	//SQ: read the favorites
	favorites_read();

	f=fopen("frontend/mame.lst","r");
	if (f)
	{
		for (i=0;i<NUMGAMES;i++)
		{
			fe_drivers[i].available=fgetc(f);
			if (fe_drivers[i].available)
				game_num_avail++;
		}
		fclose(f);
	}
	else
		game_list_init_nocache();
}
Ejemplo n.º 6
0
static void game_list_init(void)
{
	int i, j;
    int skipflag=0;
    int counter;
	int check_neogeo=0, check_other=0;

	//SQ: read the favorites
    favorites_read();	

    //SQ: Read the directory rom listing into memory to cache it for later filtering
	//We only cache the game index not the actual rom name
    if(!game_list_num) {
        DIR *d=opendir(get_documents_path("."));
        game_num_avail=0;
        if (d)
        {
			char tempstr[50];
            struct dirent *actual=readdir(d);
            while(actual)
            {
                if(strlen(actual->d_name) > 5) {
				    strcpy(tempstr, actual->d_name);
                    tempstr[(strlen(tempstr) - 4)] = '\0';	//remove .zip to compare in loop
                    for (i=0;i<NUMGAMES;i++) {
                        if (strcmp(tempstr, _drivers[i].name)==0) {
    						game_list_array[game_list_num++] = i;
                            break;
                        }
                    }
				}
                actual=readdir(d);
			}
            closedir(d);
		}
        local_game_list_num=game_list_num;
	}

    //SQ: Reset list, may happen if filter changes
    for (i=0;i<NUMGAMES;i++) {
        _drivers[i].available=0;
    }

	//SQ: Set these flags to save many string comparisons in loop below
	if (strcmp(manufact_array[global_manufacturer], "NeoGeo") == 0) check_neogeo=1;
    if (strcmp(manufact_array[global_manufacturer], "Other") == 0) check_other=1;
    
    game_num_avail=0;
    
	//SQ:game_list_array contains a list of all the ROMS in the /roms directory
    for(j=0;j<game_list_num;j++) {
        for (i=0;i<NUMGAMES;i++)
        {                
            if (!_drivers[i].available)
            {
                if (game_list_array[j] == i)     //Found a matching game
                {
                    skipflag=0;

                    //SQ:Are clones to be displayed
                    if (!global_clones && !skipflag) {
                        if (_drivers[i].clone) skipflag=1;
                    }

                    //SQ:If manufacturers is filtered, only display the relevant games
                    if (global_manufacturer && !skipflag) {
                        skipflag=1;

						//SQ:Check for Neogeo games if Neogeo selected, special case as its driver specific
                		if (check_neogeo) {
                        	if (strcmp(_drivers[i].exe, "neomame") == 0) skipflag=0;   
						} 
                		else if (check_other) {	//SQ:find all manufacturers that aren't in the list
							int x=0, mfound=0;
							while(true) {
							    if (strstr(_drivers[i].manufacturer, manufact_array[x])) {
									mfound=1;
									break;
								}
								x++;
								if(manufact_array[x][0] == '\0') break;
							}
							if(!mfound) skipflag=0;
						}
                        else if (strstr(_drivers[i].manufacturer, manufact_array[global_manufacturer])) skipflag=0;
                    }        

                    //SQ:Check category filter
                    if (global_category && !skipflag) {
                        if (!strstr(_drivers[i].category, category_array[global_category])) skipflag=1;
                    }        
                    
					//SQ:Filter by year
					if(global_year && !skipflag) {
						if((global_year + 1974) != _drivers[i].year) skipflag=1;
					}
                    
                    //SQ:Show only favorites
                    if(global_filter == 1 && !skipflag) {	
                        skipflag=1;
                        counter=0;
                        while(true) {
                            if (favarray[counter][0] == '\0') break;	//Null is the array terminator
                            if (strcasecmp(favarray[counter], _drivers[i].name) == 0) {
                                skipflag=0;
                                break;
                            }
                            counter++;
                        }
                    }

                    //SQ:Everything matches so add to list
                    if(!skipflag) {                       
                        _drivers[i].available=1;
                        game_num_avail++;
                    }
                    break;
                }
            }
        }
	}
    
}