forked from Dniel97/segatools
fixed AMFS path redirect with no E:/ drive present
This commit is contained in:
parent
629ded4018
commit
f570869946
@ -1,6 +1,6 @@
|
|||||||
# Segatools
|
# Segatools
|
||||||
|
|
||||||
Version: `2024-02-22`
|
Version: `2024-02-27`
|
||||||
|
|
||||||
Loaders and hardware emulators for SEGA games that run on the Nu and ALLS platforms.
|
Loaders and hardware emulators for SEGA games that run on the Nu and ALLS platforms.
|
||||||
|
|
||||||
|
@ -277,11 +277,12 @@ static HRESULT vfs_path_hook(const wchar_t *src, wchar_t *dest, size_t *count)
|
|||||||
const wchar_t *redir;
|
const wchar_t *redir;
|
||||||
size_t required;
|
size_t required;
|
||||||
size_t redir_len;
|
size_t redir_len;
|
||||||
|
size_t src_len;
|
||||||
|
|
||||||
assert(src != NULL);
|
assert(src != NULL);
|
||||||
assert(count != NULL);
|
assert(count != NULL);
|
||||||
|
|
||||||
if (src[0] == L'\0' || src[1] != L':' || !path_is_separator_w(src[2])) {
|
if (src[0] == L'\0' || src[1] != L':') {
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,10 +305,15 @@ static HRESULT vfs_path_hook(const wchar_t *src, wchar_t *dest, size_t *count)
|
|||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* GetFileAttributesW would request the src "E:", so fix the src_len in
|
||||||
|
in order to redirect the drive letter successfully */
|
||||||
|
|
||||||
|
src_len = path_is_separator_w(src[2]) ? 3 : 2;
|
||||||
|
|
||||||
/* Cut off <prefix>\, replace with redir path, count NUL terminator */
|
/* Cut off <prefix>\, replace with redir path, count NUL terminator */
|
||||||
|
|
||||||
redir_len = wcslen(redir);
|
redir_len = wcslen(redir);
|
||||||
required = wcslen(src) - 3 + redir_len + 1;
|
required = wcslen(src) - src_len + redir_len + 1;
|
||||||
|
|
||||||
if (dest != NULL) {
|
if (dest != NULL) {
|
||||||
if (required > *count) {
|
if (required > *count) {
|
||||||
@ -315,7 +321,7 @@ static HRESULT vfs_path_hook(const wchar_t *src, wchar_t *dest, size_t *count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wcscpy_s(dest, *count, redir);
|
wcscpy_s(dest, *count, redir);
|
||||||
wcscpy_s(dest + redir_len, *count - redir_len, src + 3);
|
wcscpy_s(dest + redir_len, *count - redir_len, src + src_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
*count = required;
|
*count = required;
|
||||||
|
Loading…
Reference in New Issue
Block a user