mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-26 04:36:56 +00:00
make file copy operation a function
add sublabels improve localization
This commit is contained in:
parent
16d1cf28f7
commit
6c936274b7
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -13,7 +13,7 @@
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"externalConsole": true,
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
|
||||
"setupCommands": [
|
||||
|
@ -675,7 +675,15 @@ MSG_HASH(
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_LIST,
|
||||
"Sideload Core"
|
||||
"Install or Restore a Core"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_ERROR,
|
||||
"Core installation failed"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_SUCCESS,
|
||||
"Core installation succesful"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_CORE_OPTIONS,
|
||||
@ -4894,6 +4902,10 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_CORE_LIST,
|
||||
"Select which core to use."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_SIDELOAD_CORE_LIST,
|
||||
"Install or restore a core from the downloads directory."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_LOAD_CONTENT_LIST,
|
||||
"Select which content to start."
|
||||
|
@ -1240,6 +1240,54 @@ static int generic_action_ok_command(enum event_command cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* TO-DO: Localization for errors */
|
||||
static bool file_copy(char* src_path, char* dst_path, char* msg, size_t size)
|
||||
{
|
||||
|
||||
FILE *src, *dst;
|
||||
char buffer[100];
|
||||
int numr, numw;
|
||||
bool ret = true;
|
||||
|
||||
src = fopen(src_path, "rb");
|
||||
|
||||
if (!src)
|
||||
{
|
||||
strlcpy(msg, "unable to open source file", size);
|
||||
ret = false;
|
||||
}
|
||||
|
||||
dst = fopen(dst_path, "wb");
|
||||
if (!dst)
|
||||
{
|
||||
strlcpy(msg, "unable to open destination file", size);
|
||||
ret = false;
|
||||
}
|
||||
|
||||
while (!feof(src))
|
||||
{
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
numr = fread(buffer, 1, 100, src);
|
||||
if (ferror(dst) != 0)
|
||||
{
|
||||
strlcpy(msg, "error reading file\n", size);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
||||
numw = fwrite(buffer, sizeof(char), numr, dst);
|
||||
if (numw != numr)
|
||||
{
|
||||
strlcpy(msg, "error writing to file\n", size);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(src);
|
||||
fclose(dst);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int generic_action_ok(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx,
|
||||
unsigned id, enum msg_hash_enums flush_id)
|
||||
@ -1310,39 +1358,24 @@ static int generic_action_ok(const char *path,
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
char destination_path[PATH_MAX_LENGTH];
|
||||
FILE *src, *dst;
|
||||
char buffer[100];
|
||||
int numr, numw;
|
||||
char message[PATH_MAX_LENGTH];
|
||||
|
||||
fill_pathname_join(destination_path, settings->paths.directory_libretro, path_basename(action_path), sizeof(destination_path));
|
||||
src = fopen(action_path, "rb");
|
||||
|
||||
if (!src)
|
||||
RARCH_LOG("Unable to open source file\n");
|
||||
|
||||
dst = fopen(destination_path, "wb");
|
||||
if (!dst)
|
||||
RARCH_LOG("Unable to open destination file\n");
|
||||
|
||||
while (!feof(src))
|
||||
if(!file_copy(action_path, destination_path, message, sizeof(message)))
|
||||
{
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
numr = fread(buffer, 1, 100, src);
|
||||
if (ferror(dst) != 0)
|
||||
{
|
||||
RARCH_LOG("File read error\n");
|
||||
break;
|
||||
}
|
||||
|
||||
numw = fwrite(buffer, sizeof(char), numr, dst);
|
||||
if (numw != numr)
|
||||
{
|
||||
RARCH_LOG("File write error\n");
|
||||
break;
|
||||
}
|
||||
runloop_msg_queue_push(msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_ERROR), 1, 100, true);
|
||||
RARCH_LOG("[sideload] %s: %s\n", msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_ERROR), message);
|
||||
RARCH_LOG(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_ERROR));
|
||||
}
|
||||
else
|
||||
{
|
||||
runloop_msg_queue_push(msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_SUCCESS), 1, 100, true);
|
||||
RARCH_LOG("[sideload] %s\n", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_SUCCESS));
|
||||
}
|
||||
fclose(src);
|
||||
fclose(dst);
|
||||
}
|
||||
break;
|
||||
case ACTION_OK_LOAD_CONFIG_FILE:
|
||||
|
@ -188,6 +188,7 @@ default_sublabel_macro(action_bind_sublabel_cheevos_username, MENU_
|
||||
default_sublabel_macro(action_bind_sublabel_cheevos_password, MENU_ENUM_SUBLABEL_CHEEVOS_PASSWORD)
|
||||
default_sublabel_macro(action_bind_sublabel_video_post_filter_record, MENU_ENUM_SUBLABEL_VIDEO_POST_FILTER_RECORD)
|
||||
default_sublabel_macro(action_bind_sublabel_core_list, MENU_ENUM_SUBLABEL_CORE_LIST)
|
||||
default_sublabel_macro(action_bind_sublabel_sideload_core_list, MENU_ENUM_SUBLABEL_SIDELOAD_CORE_LIST)
|
||||
default_sublabel_macro(action_bind_sublabel_content_list, MENU_ENUM_SUBLABEL_LOAD_CONTENT_LIST)
|
||||
default_sublabel_macro(action_bind_sublabel_content_special, MENU_ENUM_SUBLABEL_LOAD_CONTENT_SPECIAL)
|
||||
default_sublabel_macro(action_bind_sublabel_network_information, MENU_ENUM_SUBLABEL_NETWORK_INFORMATION)
|
||||
@ -1673,6 +1674,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_CORE_LIST:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_core_list);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_SIDELOAD_CORE_LIST:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_sideload_core_list);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_VIDEO_POST_FILTER_RECORD:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_post_filter_record);
|
||||
break;
|
||||
|
@ -589,9 +589,11 @@ static int ozone_list_push(void *data, void *userdata,
|
||||
{
|
||||
entry.enum_idx = MENU_ENUM_LABEL_CORE_LIST;
|
||||
menu_displaylist_setting(&entry);
|
||||
|
||||
entry.enum_idx = MENU_ENUM_LABEL_SIDELOAD_CORE_LIST;
|
||||
menu_displaylist_setting(&entry);
|
||||
if (settings->bools.menu_show_advanced_settings)
|
||||
{
|
||||
entry.enum_idx = MENU_ENUM_LABEL_SIDELOAD_CORE_LIST;
|
||||
menu_displaylist_setting(&entry);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5541,6 +5541,11 @@ static int xmb_list_push(void *data, void *userdata,
|
||||
{
|
||||
entry.enum_idx = MENU_ENUM_LABEL_CORE_LIST;
|
||||
menu_displaylist_setting(&entry);
|
||||
if (settings->bools.menu_show_advanced_settings)
|
||||
{
|
||||
entry.enum_idx = MENU_ENUM_LABEL_SIDELOAD_CORE_LIST;
|
||||
menu_displaylist_setting(&entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3703,15 +3703,13 @@ static unsigned menu_displaylist_parse_cores(
|
||||
file_type = FILE_TYPE_DIRECTORY;
|
||||
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_DIRECTORY;
|
||||
}
|
||||
else if(string_is_equal(info->path, settings->paths.directory_core_assets))
|
||||
{
|
||||
file_type = FILE_TYPE_CORE;
|
||||
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_SIDELOAD_CORE;
|
||||
}
|
||||
else
|
||||
{
|
||||
file_type = FILE_TYPE_CORE;
|
||||
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_CORE;
|
||||
if (string_is_equal(info->label, msg_hash_to_str(MENU_ENUM_LABEL_SIDELOAD_CORE_LIST)))
|
||||
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_SIDELOAD_CORE;
|
||||
else
|
||||
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_CORE;
|
||||
}
|
||||
|
||||
items_found++;
|
||||
|
@ -1572,6 +1572,8 @@ enum msg_hash_enums
|
||||
MENU_LABEL(SUBSYSTEM_LOAD),
|
||||
MENU_LABEL(CORE_LIST),
|
||||
MENU_LABEL(SIDELOAD_CORE_LIST),
|
||||
MENU_LABEL(SIDELOAD_CORE_ERROR),
|
||||
MENU_LABEL(SIDELOAD_CORE_SUCCESS),
|
||||
MENU_LABEL(MANAGEMENT),
|
||||
MENU_LABEL(ONLINE),
|
||||
MENU_LABEL(ONLINE_UPDATER),
|
||||
|
Loading…
x
Reference in New Issue
Block a user