M file_io.cpp => file_io.cpp +18 -0
@@ 723,6 723,24 @@ int DirDelete(const char *name)
return !rmdir(full_path);
}
+const char* GetNameFromPath(char *path)
+{
+ static char res[32];
+
+ char* p = strrchr(path, '/');
+ if (!p) p = path;
+ else p++;
+
+ if (strlen(p) < 19) strcpy(res, p);
+ else
+ {
+ strncpy(res, p, 19);
+ res[19] = 0;
+ }
+
+ return res;
+}
+
int FileLoad(const char *name, void *pBuffer, int size)
{
fileTYPE f;
M file_io.h => file_io.h +1 -0
@@ 116,6 116,7 @@ int DirDelete(const char *name);
//save/load from config dir
#define CONFIG_DIR "config"
+const char* GetNameFromPath(char* path);
int FileSaveConfig(const char *name, void *pBuffer, int size);
int FileLoadConfig(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
int FileDeleteConfig(const char *name);
M => +21 -2
@@ 1687,13 1687,32 @@ void HandleUI(void)
strcat(s, " ");
strcat(s, x86_get_image_name(num));
}
else if (is_pcxt() && pcxt_get_image_name(num))
else if (is_pcxt() && (p[0] == 'S') && pcxt_get_image_name(num))
{
strcpy(s, " ");
substrcpy(s + 1, p, 2);
strcat(s, " ");
strcat(s, pcxt_get_image_name(num));
}
else if (is_pcxt() && (p[0] == 'F'))
{
strcpy(s, " ");
substrcpy(s + 1, p, 2);
static char str[1024];
sprintf(str, "%s.f%c", user_io_get_core_name(), p[idx]);
if (FileLoadConfig(str, str, sizeof(str)) && str[0])
{
strcat(s, " ");
strcat(s, GetNameFromPath(str));
}
else
{
strcat(s, " *.");
pos = s + strlen(s);
substrcpy(pos, p, 1);
strcpy(pos, GetExt(pos));
}
}
else
{
if (strlen(s))
@@ 2278,7 2297,7 @@ void HandleUI(void)
}
menustate = MENU_GENERIC_MAIN1;
if (selPath[0] && !is_x86()) MenuHide();
if (selPath[0] && !is_x86() && !is_pcxt()) MenuHide();
printf("Image selected: %s\n", selPath);
memcpy(Selected_S[(int)ioctl_index], selPath, sizeof(Selected_S[(int)ioctl_index]));