mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 12:47:58 +03:00
filesystem: fix resolving case sensitive paths
Resolves #2504 and #1934.
This commit is contained in:
parent
a1f51988c7
commit
e4bc78cdbe
4 changed files with 27 additions and 16 deletions
|
@ -1,6 +1,7 @@
|
|||
## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr1-4.8.1...develop) - ××××-××-××
|
||||
- changed default FPS value to 60 (#2501)
|
||||
- fixed story so far not skipping over levels (#2506, regression from 4.8)
|
||||
- fixed resolving paths (especially to music files) on case-sensitive filesystems (#1934, #2504)
|
||||
- improved memory usage by shedding ca. 100-110 MB on average
|
||||
|
||||
## [4.8.1](https://github.com/LostArtefacts/TRX/compare/tr1-4.8...tr1-4.8.1) - 2025-02-14
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr2-0.9...develop) - ××××-××-××
|
||||
- fixed resolving paths (especially to music files) on case-sensitive filesystems (#1934, #2504)
|
||||
- improved memory usage by shedding ca. 100-110 MB on average
|
||||
|
||||
## [0.9](https://github.com/LostArtefacts/TRX/compare/tr2-0.8...tr2-0.9) - 2025-02-14
|
||||
|
|
|
@ -205,22 +205,31 @@ char *File_GetParentDirectory(const char *path)
|
|||
|
||||
char *File_GuessExtension(const char *path, const char **extensions)
|
||||
{
|
||||
if (!File_Exists(path)) {
|
||||
const char *dot = strrchr(path, '.');
|
||||
if (dot) {
|
||||
for (const char **ext = &extensions[0]; *ext; ext++) {
|
||||
size_t out_size = dot - path + strlen(*ext) + 1;
|
||||
char *out = Memory_Alloc(out_size);
|
||||
strncpy(out, path, dot - path);
|
||||
out[dot - path] = '\0';
|
||||
strcat(out, *ext);
|
||||
if (File_Exists(out)) {
|
||||
return out;
|
||||
}
|
||||
Memory_FreePointer(&out);
|
||||
}
|
||||
}
|
||||
if (File_Exists(path)) {
|
||||
goto fallback;
|
||||
}
|
||||
|
||||
const char *dot = strrchr(path, '.');
|
||||
if (dot == nullptr) {
|
||||
goto fallback;
|
||||
}
|
||||
|
||||
for (const char **ext = &extensions[0]; *ext; ext++) {
|
||||
size_t out_size = dot - path + strlen(*ext) + 1;
|
||||
char *out = Memory_Alloc(out_size);
|
||||
strncpy(out, path, dot - path);
|
||||
out[dot - path] = '\0';
|
||||
strcat(out, *ext);
|
||||
|
||||
char *full_path = File_GetFullPath(out);
|
||||
Memory_FreePointer(&out);
|
||||
if (M_ExistsRaw(full_path)) {
|
||||
return full_path;
|
||||
}
|
||||
Memory_FreePointer(&full_path);
|
||||
}
|
||||
|
||||
fallback:
|
||||
return Memory_DupStr(path);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ static char *M_GetTrackFileName(const char *base_dir, int32_t track)
|
|||
char file_path[64];
|
||||
sprintf(file_path, "%s/track%02d.flac", base_dir, track);
|
||||
char *result = File_GuessExtension(file_path, m_ExtensionsToTry);
|
||||
if (!File_Exists(file_path)) {
|
||||
if (!File_Exists(result)) {
|
||||
Memory_FreePointer(&result);
|
||||
sprintf(file_path, "%s/%d.flac", base_dir, track);
|
||||
result = File_GuessExtension(file_path, m_ExtensionsToTry);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue