From 234dc99fd3c3d0358e4247a8ac86e4c832ca7994 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Mon, 2 Dec 2024 08:05:01 +0100 Subject: [PATCH] RISCOS: Don't encode path when it's not needed Also disable atomic support as it may fail to write when file names are long. --- backends/fs/stdiostream.cpp | 4 ++++ common/path.cpp | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/backends/fs/stdiostream.cpp b/backends/fs/stdiostream.cpp index cc03e78321c9..db2cb7bd60b1 100644 --- a/backends/fs/stdiostream.cpp +++ b/backends/fs/stdiostream.cpp @@ -43,6 +43,10 @@ // Atari file names must have a 8.3 format, atomic breaks this #define STDIOSTREAM_NO_ATOMIC_SUPPORT #endif +#if defined(RISCOS) +// RISC OS file names are expected to be 10 characters or less, atomic makes this hard to guarantee +#define STDIOSTREAM_NO_ATOMIC_SUPPORT +#endif StdioStream::StdioStream(void *handle) : _handle(handle), _path(nullptr) { assert(handle); diff --git a/common/path.cpp b/common/path.cpp index 5b413e3dcbba..65e451fea65f 100644 --- a/common/path.cpp +++ b/common/path.cpp @@ -1177,13 +1177,21 @@ String Path::toConfig() const { return toString(Path::kNativeSeparator); } } -#elif defined(__3DS__) || defined(__amigaos4__) || defined(__DS__) || defined(__MORPHOS__) || defined(NINTENDO_SWITCH) || defined(__PSP__) || defined(PSP2) || defined(__WII__) || defined(WIN32) +#elif defined(__3DS__) || defined(__amigaos4__) || defined(__DS__) || defined(__MORPHOS__) || defined(NINTENDO_SWITCH) || defined(__PSP__) || defined(PSP2) || defined(RISCOS) || defined(__WII__) || defined(WIN32) // For all platforms making use of : as a drive separator, avoid useless punycoding if (!isEscaped()) { // If we are escaped, we have forbidden characters which must be encoded // Try to replace all : by SEPARATOR and check if we need puny encoding: if we don't, we are safe Path tmp(*this); tmp._str.replace(':', SEPARATOR); +#if defined(RISCOS) + // RiscOS uses these characters everywhere + tmp._str.replace('$', SEPARATOR); + tmp._str.replace('<', SEPARATOR); + tmp._str.replace('>', SEPARATOR); + // We can get ending dots when we replace $ (.$ suffix) + tmp._str.replace('.', SEPARATOR); +#endif #if defined(WIN32) // WIN32 can also make use of ? in Win32 devices namespace tmp._str.replace('?', SEPARATOR);