forked from Dniel97/segatools
hooklib/path.c: add slash-insensitive path comparison API
This commit is contained in:
parent
03c7954ada
commit
54cd2f6e9a
@ -388,6 +388,35 @@ end:
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int path_compare_w(const wchar_t *string1, const wchar_t *string2, size_t count)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
wchar_t c1, c2;
|
||||||
|
|
||||||
|
assert(string1 != NULL);
|
||||||
|
assert(string2 != NULL);
|
||||||
|
|
||||||
|
for (i = 0; i < count && string1[i] && string2[i]; i++) {
|
||||||
|
c1 = towlower(string1[i]);
|
||||||
|
|
||||||
|
if (c1 == '/') {
|
||||||
|
c1 = '\\';
|
||||||
|
}
|
||||||
|
|
||||||
|
c2 = towlower(string2[i]);
|
||||||
|
|
||||||
|
if (c2 == '/') {
|
||||||
|
c2 = '\\';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c1 != c2) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i == count ? 0 : string2[i] - string1[i];
|
||||||
|
}
|
||||||
|
|
||||||
/* Dumping ground for kernel32 file system ops whose path parameters we have to
|
/* Dumping ground for kernel32 file system ops whose path parameters we have to
|
||||||
hook into and translate. This list will grow over time as we go back and
|
hook into and translate. This list will grow over time as we go back and
|
||||||
fix up older games that don't pay attention to the mount point registry. */
|
fix up older games that don't pay attention to the mount point registry. */
|
||||||
|
@ -10,3 +10,4 @@ typedef HRESULT (*path_hook_t)(
|
|||||||
size_t *count);
|
size_t *count);
|
||||||
|
|
||||||
HRESULT path_hook_push(path_hook_t hook);
|
HRESULT path_hook_push(path_hook_t hook);
|
||||||
|
int path_compare_w(const wchar_t *string1, const wchar_t *string2, size_t count);
|
||||||
|
@ -273,7 +273,7 @@ static HRESULT vfs_path_hook_nthome(
|
|||||||
|
|
||||||
/* Case-insensitive check to see if src starts with vfs_nthome */
|
/* Case-insensitive check to see if src starts with vfs_nthome */
|
||||||
|
|
||||||
if (_wcsnicmp(src, vfs_nthome, vfs_nthome_len) != 0) {
|
if (path_compare_w(src, vfs_nthome, vfs_nthome_len) != 0) {
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user