Fix/implement RISC OS path handling
This commit is contained in:
parent
e18003bb14
commit
a4ae3af444
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -62,6 +62,10 @@
|
|||
#include "core/fsservices.h"
|
||||
#include "core/errorutil.h"
|
||||
|
||||
#if IS_RISCOS
|
||||
#include <unixlib/local.h>
|
||||
#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<char> 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
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue