diff --git a/src/core/file.h b/src/core/file.h index e9de698..da9f45b 100644 --- a/src/core/file.h +++ b/src/core/file.h @@ -155,10 +155,20 @@ public: static bool IsAbsolutePath(const TSTRING& in); }; +class cRiscosPath +{ +public: + static TSTRING AsPosix(const TSTRING& in); + static TSTRING AsNative(const TSTRING& in); + static bool IsAbsolutePath(const TSTRING& in); +}; + #if IS_DOS_DJGPP #define cDevicePath cDosPath #elif IS_AROS #define cDevicePath cArosPath +#elif IS_RISCOS +#define cDevicePath cRiscosPath #endif diff --git a/src/core/file_unix.cpp b/src/core/file_unix.cpp index f5bad8a..2bda72b 100644 --- a/src/core/file_unix.cpp +++ b/src/core/file_unix.cpp @@ -62,6 +62,10 @@ #include "core/fsservices.h" #include "core/errorutil.h" +#if IS_RISCOS +#include +#endif + /////////////////////////////////////////////////////////////////////////// // cFile_i : Insulated implementation for cFile objects. /////////////////////////////////////////////////////////////////////////// @@ -89,7 +93,7 @@ cFile_i::~cFile_i() fclose( mpCurrStream ); mpCurrStream = NULL; -#if IS_AROS +#if IS_AROS || IS_RISCOS if( mFlags & cFile::OPEN_LOCKED_TEMP ) { // unlink this file @@ -205,7 +209,7 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags ) } mpData->m_fd = fh; -#if !IS_AROS +#if !IS_AROS && !IS_RISCOS if( flags & OPEN_LOCKED_TEMP ) { // unlink this file @@ -565,3 +569,65 @@ TSTRING cArosPath::AsNative( const TSTRING& in ) return out; } + +bool cRiscosPath::IsAbsolutePath(const TSTRING& in) +{ + if (in.empty()) + return false; + + if (in[0] == '/') + return true; + + if (in.find("$") != std::string::npos) + return true; + + return false; +} + +// For paths of type SDFS::Volume.$.dir.file +TSTRING cRiscosPath::AsPosix( const TSTRING& in ) +{ +#if IS_RISCOS + if (in[0] == '/') + { + return in; + } + + TSTRING out; + char* unixified = __unixify(in.c_str(), 0,0,0,0); + if(unixified) + { + out.assign(unixified); + free(unixified); + return out; + } + return in; + +#else + return in; +#endif +} + +TSTRING cRiscosPath::AsNative( const TSTRING& in ) +{ +#if IS_RISCOS + if (in[0] != '/') + { + return in; + } + + TSTRING out; + int buf_size = in.length() + 100; // examples pad by 100 + std::vector buf(buf_size); + __riscosify(in.c_str(), 0,0, &buf[0], buf_size, 0); + if(buf[0]) + { + out.assign(&buf[0]); + return out; + } + return in; +#else + return in; +#endif +} + diff --git a/src/core/platform.h b/src/core/platform.h index cfb424f..c58e3c8 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -305,7 +305,7 @@ #define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS && !IS_RISCOS) #define NEEDS_SWAB_IMPL (IS_CYGWIN || IS_SYLLABLE || IS_ANDROID || IS_SORTIX) #define USES_MBLEN (!IS_ANDROID && !IS_AROS) -#define USES_DEVICE_PATH (IS_AROS || IS_DOS_DJGPP) +#define USES_DEVICE_PATH (IS_AROS || IS_DOS_DJGPP || IS_RISCOS) #define ICONV_CONST_SOURCE (IS_MINIX) #define SUPPORTS_DIRECT_IO (IS_LINUX) // Linux is the only platform where direct i/o hashing has been tested & works properly so far. diff --git a/src/tripwire/twcmdline.cpp b/src/tripwire/twcmdline.cpp index 5a855d0..39e9577 100644 --- a/src/tripwire/twcmdline.cpp +++ b/src/tripwire/twcmdline.cpp @@ -264,22 +264,26 @@ static void util_InitTempDirectory(const cConfigFile& cf) temp_directory = "T:"; #elif IS_DOS_DJGPP temp_directory = "/dev/c/temp/"; +#elif IS_RISCOS + temp_directory = "/!BOOT/Resources/!Scrap/ScrapDirs/ScrapDir"; #else temp_directory = "/tmp/"; #endif } +#if !IS_RISCOS // make sure we have a trailing slash -- thanks Jarno... // if (*temp_directory.rbegin() != '/') { temp_directory.push_back('/'); } +#endif // make sure it exists... // -#if IS_AROS +#if IS_AROS || IS_RISCOS temp_directory = cDevicePath::AsNative(temp_directory); #elif IS_DOS_DJGPP temp_directory = cDevicePath::AsPosix(temp_directory); @@ -295,6 +299,13 @@ static void util_InitTempDirectory(const cConfigFile& cf) } else { +#if IS_RISCOS + if (*temp_directory.rbegin() != '.') + { + temp_directory.push_back('.'); + } +#endif + iFSServices::GetInstance()->SetTempDirName(temp_directory); } }