diff --git a/src/Audio.c b/src/Audio.c index 84793bd78..03442ad96 100644 --- a/src/Audio.c +++ b/src/Audio.c @@ -221,9 +221,11 @@ static cc_result ProcessZipEntry(const cc_string* path, struct Stream* stream, s static cc_result Sounds_ExtractZip(const cc_string* path) { struct ZipEntry entries[128]; struct Stream stream; + cc_filepath raw_path; cc_result res; - res = Stream_OpenFile(&stream, path); + Platform_EncodePath(&raw_path, path); + res = Stream_OpenPath(&stream, &raw_path); if (res) { Logger_SysWarn2(res, "opening", path); return res; } res = Zip_Extract(&stream, SelectZipEntry, ProcessZipEntry, @@ -422,6 +424,7 @@ static void Music_RunLoop(void) { cc_string path; RNGState rnd; struct Stream stream; + cc_filepath raw_path; int idx, delay; cc_result res = 0; @@ -438,7 +441,8 @@ static void Music_RunLoop(void) { path = StringsBuffer_UNSAFE_Get(&files, idx); Platform_Log1("playing music file: %s", &path); - res = Stream_OpenFile(&stream, &path); + Platform_EncodePath(&raw_path, &path); + res = Stream_OpenPath(&stream, &raw_path); if (res) { Logger_SysWarn2(res, "opening", &path); break; } res = Music_PlayOgg(&stream); diff --git a/src/Formats.c b/src/Formats.c index 576c093d6..eb8d026f5 100644 --- a/src/Formats.c +++ b/src/Formats.c @@ -67,11 +67,14 @@ cc_result Map_LoadFrom(const cc_string* path) { struct LocationUpdate update = { 0 }; struct MapImporter* imp; struct Stream stream; + cc_filepath raw_path; cc_result res; + Game_Reset(); - spawn_point = &update; - res = Stream_OpenFile(&stream, path); + + Platform_EncodePath(&raw_path, path); + res = Stream_OpenPath(&stream, &raw_path); if (res) { Logger_SysWarn2(res, "opening", path); return res; } imp = MapImporter_Find(path); diff --git a/src/Launcher.c b/src/Launcher.c index 246fbd979..d9b8c50b1 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -463,9 +463,11 @@ static cc_result Launcher_ProcessZipEntry(const cc_string* path, struct Stream* static cc_result ExtractTexturePack(const cc_string* path) { struct ZipEntry entries[32]; struct Stream stream; + cc_filepath raw_path; cc_result res; - res = Stream_OpenFile(&stream, path); + Platform_EncodePath(&raw_path, path); + res = Stream_OpenPath(&stream, &raw_path); if (res == ReturnCode_FileNotFound) return res; if (res) { Logger_SysWarn(res, "opening texture pack"); return res; } diff --git a/src/Platform_Posix.c b/src/Platform_Posix.c index acf874f41..2d21e4769 100644 --- a/src/Platform_Posix.c +++ b/src/Platform_Posix.c @@ -1466,15 +1466,15 @@ static void DecodeMachineID(char* tmp, int len, cc_uint32* key) { #if defined CC_BUILD_LINUX /* Read /var/lib/dbus/machine-id or /etc/machine-id for the key */ static cc_result GetMachineID(cc_uint32* key) { - const cc_string idFile = String_FromConst("/var/lib/dbus/machine-id"); - const cc_string altFile = String_FromConst("/etc/machine-id"); + const cc_filepath* id_path = FILEPATH_RAW("/var/lib/dbus/machine-id"); + const cc_filepath* alt_path = FILEPATH_RAW("/etc/machine-id"); char tmp[MACHINEID_LEN]; struct Stream s; cc_result res; /* Some machines only have dbus id, others only have etc id */ - res = Stream_OpenFile(&s, &idFile); - if (res) res = Stream_OpenFile(&s, &altFile); + res = Stream_OpenPath(&s, id_path); + if (res) res = Stream_OpenPath(&s, alt_path); if (res) return res; res = Stream_Read(&s, (cc_uint8*)tmp, MACHINEID_LEN); diff --git a/src/TexturePack.c b/src/TexturePack.c index 4b9d0d4f4..730e4b685 100644 --- a/src/TexturePack.c +++ b/src/TexturePack.c @@ -375,17 +375,22 @@ static int IsCached(const cc_string* url) { static cc_bool OpenCachedData(const cc_string* url, struct Stream* stream) { cc_string mainPath; char mainBuffer[FILENAME_SIZE]; cc_string altPath; char altBuffer[FILENAME_SIZE]; + cc_filepath raw_path; cc_result res; + String_InitArray(mainPath, mainBuffer); String_InitArray(altPath, altBuffer); MakeCachePath(&mainPath, &altPath, url); - res = Stream_OpenFile(stream, &mainPath); + Platform_EncodePath(&raw_path, &mainPath); + res = Stream_OpenPath(stream, &raw_path); /* try fallback cache if can't find in main cache */ - if (res == ReturnCode_FileNotFound && altPath.length) - res = Stream_OpenFile(stream, &altPath); + if (res == ReturnCode_FileNotFound && altPath.length) { + Platform_EncodePath(&raw_path, &altPath); + res = Stream_OpenPath(stream, &raw_path); + } if (res == ReturnCode_FileNotFound) return false; if (res) { Logger_SysWarn2(res, "opening cache for", url); return false; } @@ -595,9 +600,11 @@ static cc_result ExtractFromFile(const cc_string* path) { #else static cc_result ExtractFromFile(const cc_string* path) { struct Stream stream; + cc_filepath raw_path; cc_result res; - res = Stream_OpenFile(&stream, path); + Platform_EncodePath(&raw_path, path); + res = Stream_OpenPath(&stream, &raw_path); if (res) { Logger_SysWarn2(res, "opening", path); return res; } res = ExtractFrom(&stream, path);