mirror of
https://github.com/Oibaf66/fbzx-wii.git
synced 2024-11-28 02:54:15 +01:00
Added file managing (paste, copy and delete)
This commit is contained in:
parent
ca2919097f
commit
7271ef5102
@ -75,12 +75,16 @@ char path_mdrs[MAX_PATH_LENGTH];
|
||||
char path_scr1[MAX_PATH_LENGTH];
|
||||
char path_scr2[MAX_PATH_LENGTH];
|
||||
char path_confs[MAX_PATH_LENGTH];
|
||||
char path_paste[MAX_PATH_LENGTH];
|
||||
char path_copy[MAX_PATH_LENGTH];
|
||||
char path_delete[MAX_PATH_LENGTH];
|
||||
char path_tmp[MAX_PATH_LENGTH];
|
||||
char load_path_snaps[MAX_PATH_LENGTH];
|
||||
char load_path_taps[MAX_PATH_LENGTH];
|
||||
char load_path_scr1[MAX_PATH_LENGTH];
|
||||
char load_path_poke[MAX_PATH_LENGTH];
|
||||
char rom_cartridge[MAX_PATH_LENGTH];
|
||||
char pasted_file[MAX_PATH_LENGTH];
|
||||
|
||||
unsigned int colors[80];
|
||||
unsigned int jump_frames,curr_frames, turbo_n;
|
||||
@ -1507,6 +1511,9 @@ int main(int argc,char *argv[])
|
||||
strcpy(path_scr2,path_snaps);
|
||||
strcpy(path_confs,path_snaps);
|
||||
strcpy(load_path_poke,path_snaps);
|
||||
strcpy(path_paste,path_snaps);
|
||||
strcpy(path_delete,path_snaps);
|
||||
strcpy(path_copy,path_snaps);
|
||||
strcpy(path_tmp,path_snaps);
|
||||
strcat(path_snaps,"snapshots");
|
||||
strcat(path_taps,"tapes");
|
||||
@ -1519,6 +1526,8 @@ int main(int argc,char *argv[])
|
||||
strcpy(load_path_snaps,path_snaps);
|
||||
strcpy(load_path_taps,path_taps);
|
||||
strcpy(load_path_scr1,path_scr1);
|
||||
|
||||
pasted_file[0]=0;
|
||||
|
||||
//Remove and make tmp dir
|
||||
|
||||
@ -1554,6 +1563,7 @@ int main(int argc,char *argv[])
|
||||
strcpy(load_path_taps,"sd:/");
|
||||
strcpy(load_path_scr1,"sd:/");
|
||||
strcpy(load_path_poke,"sd:/");
|
||||
strcpy(path_paste,"sd:/");
|
||||
}
|
||||
else ordenador.port =0;
|
||||
break;
|
||||
@ -1564,6 +1574,7 @@ int main(int argc,char *argv[])
|
||||
strcpy(load_path_taps,"usb:/");
|
||||
strcpy(load_path_scr1,"usb:/");
|
||||
strcpy(load_path_poke,"usb:/");
|
||||
strcpy(path_paste,"usb:/");
|
||||
}
|
||||
else ordenador.port =0;
|
||||
break;
|
||||
@ -1574,6 +1585,7 @@ int main(int argc,char *argv[])
|
||||
strcpy(load_path_taps,"smb:/");
|
||||
strcpy(load_path_scr1,"smb:/");
|
||||
strcpy(load_path_poke,"smb:/");
|
||||
strcpy(path_paste,"smb:/");
|
||||
}
|
||||
else ordenador.port =0;
|
||||
break;
|
||||
@ -1584,6 +1596,7 @@ int main(int argc,char *argv[])
|
||||
strcpy(load_path_taps,"ftp:/");
|
||||
strcpy(load_path_scr1,"ftp:/");
|
||||
strcpy(load_path_poke,"ftp:/");
|
||||
strcpy(path_paste,"ftp:/");
|
||||
}
|
||||
else ordenador.port =0;
|
||||
break;
|
||||
|
@ -39,12 +39,16 @@ extern char path_mdrs[MAX_PATH_LENGTH];
|
||||
extern char path_scr1[MAX_PATH_LENGTH];
|
||||
extern char path_scr2[MAX_PATH_LENGTH];
|
||||
extern char path_confs[MAX_PATH_LENGTH];
|
||||
extern char path_paste[MAX_PATH_LENGTH];
|
||||
extern char path_copy[MAX_PATH_LENGTH];
|
||||
extern char path_delete[MAX_PATH_LENGTH];
|
||||
extern char path_tmp[MAX_PATH_LENGTH];
|
||||
extern char load_path_snaps[MAX_PATH_LENGTH];
|
||||
extern char load_path_taps[MAX_PATH_LENGTH];
|
||||
extern char load_path_scr1[MAX_PATH_LENGTH];
|
||||
extern char load_path_poke[MAX_PATH_LENGTH];
|
||||
extern char rom_cartridge[MAX_PATH_LENGTH];
|
||||
extern char pasted_file[MAX_PATH_LENGTH];
|
||||
|
||||
extern unsigned int colors[80];
|
||||
extern unsigned int jump_frames,curr_frames, turbo_n;
|
||||
|
143
src/gui_sdl.c
143
src/gui_sdl.c
@ -179,16 +179,18 @@ static const char *tools_messages[] = {
|
||||
/*01*/ "^|Save1|Save2|Load|Delete",
|
||||
/*02*/ "Port",
|
||||
/*03*/ "^|default|sd|usb|smb|ftp",
|
||||
/*04*/ "Auto virtual keyboard",
|
||||
/*05*/ "^|on|off",
|
||||
/*06*/ "Keyboard rumble",
|
||||
/*04*/ "Manage files",
|
||||
/*05*/ "^|Paste|Copy|Delete",
|
||||
/*06*/ "Auto virtual keyboard",
|
||||
/*07*/ "^|on|off",
|
||||
/*08*/ " ",
|
||||
/*09*/ "Load poke file",
|
||||
/*08*/ "Keyboard rumble",
|
||||
/*09*/ "^|on|off",
|
||||
/*10*/ " ",
|
||||
/*11*/ "Insert poke",
|
||||
/*11*/ "Load poke file",
|
||||
/*12*/ " ",
|
||||
/*13*/ "Help",
|
||||
/*13*/ "Insert poke",
|
||||
/*14*/ " ",
|
||||
/*15*/ "Help",
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -1318,6 +1320,7 @@ static void set_port(int which)
|
||||
strcpy(load_path_taps,load_path_snaps);
|
||||
strcpy(load_path_scr1,load_path_snaps);
|
||||
strcpy(load_path_poke,load_path_snaps);
|
||||
strcpy(path_paste,load_path_snaps);
|
||||
strcat(load_path_snaps,"snapshots");
|
||||
strcat(load_path_taps,"tapes");
|
||||
strcat(load_path_scr1,"scr");
|
||||
@ -1331,6 +1334,7 @@ static void set_port(int which)
|
||||
strcpy(load_path_taps,"sd:/");
|
||||
strcpy(load_path_scr1,"sd:/");
|
||||
strcpy(load_path_poke,"sd:/");
|
||||
strcpy(path_paste,"sd:/");
|
||||
ordenador.port = which;}
|
||||
else
|
||||
msgInfo("SD is not mounted",3000,NULL);
|
||||
@ -1341,6 +1345,7 @@ static void set_port(int which)
|
||||
strcpy(load_path_taps,"usb:/");
|
||||
strcpy(load_path_scr1,"usb:/");
|
||||
strcpy(load_path_poke,"usb:/");
|
||||
strcpy(path_paste,"usb:/");
|
||||
ordenador.port = which;}
|
||||
else
|
||||
msgInfo("USB is not mounted",3000,NULL);
|
||||
@ -1358,6 +1363,7 @@ static void set_port(int which)
|
||||
strcpy(load_path_taps,"smb:/");
|
||||
strcpy(load_path_scr1,"smb:/");
|
||||
strcpy(load_path_poke,"smb:/");
|
||||
strcpy(path_paste,"smb:/");
|
||||
ordenador.port = which;}
|
||||
else
|
||||
msgInfo("SMB is not mounted",3000,NULL);
|
||||
@ -1376,6 +1382,7 @@ static void set_port(int which)
|
||||
strcpy(load_path_taps,"ftp:/");
|
||||
strcpy(load_path_scr1,"ftp:/");
|
||||
strcpy(load_path_poke,"ftp:/");
|
||||
strcpy(path_paste,"ftp:/");
|
||||
ordenador.port = which;}
|
||||
else
|
||||
msgInfo("FTP is not mounted",3000,NULL);
|
||||
@ -1696,10 +1703,113 @@ switch (which)
|
||||
return retorno;
|
||||
}
|
||||
|
||||
static void delete_file()
|
||||
{
|
||||
const char *filename = menu_select_file(path_delete, NULL, 0);
|
||||
|
||||
if (filename==NULL) // Aborted
|
||||
return;
|
||||
|
||||
if ((strstr(filename,"None") == NULL)&&(msgYesNo("Delete the file?", 0, -1, -1))) unlink(filename);
|
||||
|
||||
free((void *)filename);
|
||||
}
|
||||
|
||||
static void paste_file()
|
||||
{
|
||||
const char *filename = menu_select_file(path_paste, NULL, 0);
|
||||
|
||||
if (filename==NULL) // Aborted
|
||||
return;
|
||||
|
||||
if (strstr(filename,"None") == NULL)
|
||||
{
|
||||
strcpy(pasted_file, filename);
|
||||
msgInfo("File pasted", 2000,NULL) ;
|
||||
}
|
||||
|
||||
free((void *)filename);
|
||||
}
|
||||
|
||||
static void copy_file()
|
||||
{
|
||||
char copy_full_name[MAX_PATH_LENGTH];
|
||||
char paste_name[81];
|
||||
FILE *from_file, *to_file;
|
||||
int c;
|
||||
|
||||
if (pasted_file[0]==0) {msgInfo("No file pasted", 2000,NULL) ;return;}
|
||||
|
||||
msgInfo("Select \"None\" in the dir", 2000,NULL) ;
|
||||
|
||||
const char *filename = menu_select_file(path_copy, pasted_file, 0);
|
||||
|
||||
if (filename==NULL) // Aborted
|
||||
return;
|
||||
|
||||
if (strstr(filename,"None") == NULL) //We have to select None
|
||||
goto exit;
|
||||
|
||||
|
||||
if (strrchr(filename, '/')) *(strrchr(filename, '/')+1) = 0; //remove the filename
|
||||
|
||||
strncpy(copy_full_name, filename, MAX_PATH_LENGTH);
|
||||
|
||||
if (strrchr(pasted_file, '/'))
|
||||
strncpy(paste_name, strrchr(pasted_file, '/') + 1, 80);
|
||||
else
|
||||
strncpy(paste_name, pasted_file, 80);
|
||||
|
||||
strcat(copy_full_name,paste_name);
|
||||
|
||||
from_file=fopen(pasted_file, "rb");
|
||||
|
||||
if (!from_file) goto exit;
|
||||
|
||||
to_file=fopen(copy_full_name, "wb");
|
||||
|
||||
if (!to_file) {fclose (from_file);goto exit;}
|
||||
|
||||
while ((c = getc(from_file)) != EOF)
|
||||
putc(c, to_file);
|
||||
|
||||
fclose (from_file);
|
||||
fclose (to_file);
|
||||
pasted_file[0]=0;
|
||||
msgInfo("File copied", 2000,NULL) ;
|
||||
|
||||
exit:
|
||||
|
||||
free((void *)filename);
|
||||
}
|
||||
|
||||
|
||||
static int manage_file(int which)
|
||||
{
|
||||
int retorno = 0; //Stay in menu as default
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case 0: // paste
|
||||
paste_file();
|
||||
break;
|
||||
case 1: // save
|
||||
copy_file();
|
||||
break;
|
||||
case 2: // delete
|
||||
delete_file();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return retorno;
|
||||
}
|
||||
|
||||
static int tools()
|
||||
{
|
||||
int opt , retorno;
|
||||
int submenus[4], old_port;
|
||||
int submenus[5], old_port;
|
||||
|
||||
memset(submenus, 0, sizeof(submenus));
|
||||
|
||||
@ -1707,8 +1817,8 @@ static int tools()
|
||||
retorno=-1; //Exit from menu as default
|
||||
|
||||
submenus[1] = ordenador.port;
|
||||
submenus[2] = !ordenador.vk_auto;
|
||||
submenus[3] = !ordenador.vk_rumble;
|
||||
submenus[3] = !ordenador.vk_auto;
|
||||
submenus[4] = !ordenador.vk_rumble;
|
||||
|
||||
old_port=ordenador.port;
|
||||
|
||||
@ -1718,21 +1828,24 @@ static int tools()
|
||||
return 0;
|
||||
|
||||
if (old_port!= submenus[1]) set_port(submenus[1]);
|
||||
ordenador.vk_auto = !submenus[2];
|
||||
ordenador.vk_rumble = !submenus[3];
|
||||
ordenador.vk_auto = !submenus[3];
|
||||
ordenador.vk_rumble = !submenus[4];
|
||||
|
||||
switch(opt)
|
||||
{
|
||||
case 0:
|
||||
retorno = manage_scr(submenus[0]);
|
||||
break;
|
||||
case 9: // Load poke file
|
||||
case 4:
|
||||
retorno = manage_file(submenus[2]);
|
||||
break;
|
||||
case 11: // Load poke file
|
||||
retorno = load_poke_file();
|
||||
break;
|
||||
case 11: // Insert poke
|
||||
case 13: // Insert poke
|
||||
retorno = do_poke_sdl();
|
||||
break;
|
||||
case 13:
|
||||
case 15:
|
||||
help();
|
||||
retorno = -1;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user