qt: Fix HDD path relativization on Windows
This commit is contained in:
@@ -710,7 +710,11 @@ usage:
|
||||
if (rom_path[0] != '\0')
|
||||
pclog("# ROM path: %s\n", rom_path);
|
||||
else
|
||||
pclog("# ROM path: %sroms\\\n", exe_path);
|
||||
#ifndef _WIN32
|
||||
pclog("# ROM path: %sroms/\n", exe_path);
|
||||
#else
|
||||
pclog("# ROM path: %sroms\\\n", exe_path);
|
||||
#endif
|
||||
pclog("# Configuration file: %s\n#\n\n", cfg_path);
|
||||
/*
|
||||
* We are about to read the configuration file, which MAY
|
||||
|
@@ -1402,6 +1402,7 @@ load_hard_disks(void)
|
||||
} else {
|
||||
plat_append_filename(hdd[c].fn, usr_path, p);
|
||||
}
|
||||
plat_path_normalize(hdd[c].fn);
|
||||
|
||||
/* If disk is empty or invalid, mark it for deletion. */
|
||||
if (! hdd_is_valid(c)) {
|
||||
@@ -2810,11 +2811,13 @@ save_hard_disks(void)
|
||||
}
|
||||
|
||||
sprintf(temp, "hdd_%02i_fn", c+1);
|
||||
if (hdd_is_valid(c) && (strlen(hdd[c].fn) != 0))
|
||||
if (hdd_is_valid(c) && (strlen(hdd[c].fn) != 0)) {
|
||||
plat_path_normalize(hdd[c].fn);
|
||||
if (!strnicmp(hdd[c].fn, usr_path, strlen(usr_path)))
|
||||
config_set_string(cat, temp, &hdd[c].fn[strlen(usr_path)]);
|
||||
else
|
||||
config_set_string(cat, temp, hdd[c].fn);
|
||||
}
|
||||
else
|
||||
config_delete_var(cat, temp);
|
||||
}
|
||||
|
@@ -252,6 +252,10 @@ hdd_image_load(int id)
|
||||
int vhd_error = 0;
|
||||
|
||||
memset(empty_sector, 0, sizeof(empty_sector));
|
||||
if (fn) {
|
||||
plat_path_normalize(fn);
|
||||
}
|
||||
|
||||
|
||||
hdd_images[id].base = 0;
|
||||
|
||||
|
@@ -111,6 +111,7 @@ extern char *plat_get_extension(char *s);
|
||||
extern void plat_append_filename(char *dest, const char *s1, const char *s2);
|
||||
extern void plat_put_backslash(char *s);
|
||||
extern void plat_path_slash(char *path);
|
||||
extern void plat_path_normalize(char *path);
|
||||
extern int plat_path_abs(char *path);
|
||||
extern int plat_dir_check(char *path);
|
||||
extern int plat_dir_create(char *path);
|
||||
|
@@ -235,15 +235,25 @@ plat_path_abs(char *path)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
plat_path_normalize(char* path)
|
||||
{
|
||||
while (*path++ != 0)
|
||||
{
|
||||
if (*path == '\\') *path = '/';
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
plat_path_slash(char *path)
|
||||
{
|
||||
auto len = strlen(path);
|
||||
auto separator = QDir::separator().toLatin1();
|
||||
auto separator = '/';
|
||||
if (path[len-1] != separator) {
|
||||
path[len] = separator;
|
||||
path[len+1] = 0;
|
||||
}
|
||||
plat_path_normalize(path);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -282,12 +282,22 @@ plat_path_abs(char *path)
|
||||
return path[0] == '/';
|
||||
}
|
||||
|
||||
void
|
||||
plat_path_normalize(char* path)
|
||||
{
|
||||
while (*path++ != 0)
|
||||
{
|
||||
if (*path == '\\') *path = '/';
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
plat_path_slash(char *path)
|
||||
{
|
||||
if ((path[strlen(path)-1] != '/')) {
|
||||
strcat(path, "/");
|
||||
}
|
||||
plat_path_normalize(path);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -731,6 +731,11 @@ plat_remove(char *path)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
plat_path_normalize(char* path)
|
||||
{
|
||||
/* No-op */
|
||||
}
|
||||
|
||||
/* Make sure a path ends with a trailing (back)slash. */
|
||||
void
|
||||
|
Reference in New Issue
Block a user