Add Posix<-->Native path conversion, and handle absence of Unix unlinked-but-open tempfile trick on AROS
This commit is contained in:
parent
ec90cdc0a5
commit
e71023730e
|
@ -73,8 +73,7 @@ class cFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#if IS_UNIX
|
#if IS_UNIX
|
||||||
typedef off_t File_t;
|
typedef off_t File_t;
|
||||||
|
|
||||||
#else //WIN32
|
#else //WIN32
|
||||||
typedef int64 File_t;
|
typedef int64 File_t;
|
||||||
|
|
||||||
|
@ -140,5 +139,16 @@ public:
|
||||||
bool isWritable;
|
bool isWritable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __AROS__
|
||||||
|
class cArosPath
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static TSTRING AsPosix(const TSTRING& in);
|
||||||
|
static TSTRING AsNative(const TSTRING& in);
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif //__FILE_H
|
#endif //__FILE_H
|
||||||
|
|
||||||
|
|
|
@ -119,8 +119,15 @@ cFile::~cFile()
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Open
|
// Open
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __AROS
|
||||||
void cFile::Open( const TSTRING& sFileName, uint32 flags )
|
void cFile::Open( const TSTRING& sFileName, uint32 flags )
|
||||||
{
|
{
|
||||||
|
#else
|
||||||
|
void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
||||||
|
{
|
||||||
|
TSTRING sFileName = cArosPath::AsNative(sFileNameC);
|
||||||
|
#endif
|
||||||
mode_t openmode = 0664;
|
mode_t openmode = 0664;
|
||||||
if ( mpData->mpCurrStream != NULL )
|
if ( mpData->mpCurrStream != NULL )
|
||||||
Close();
|
Close();
|
||||||
|
@ -161,6 +168,7 @@ void cFile::Open( const TSTRING& sFileName, uint32 flags )
|
||||||
if ( flags & OPEN_CREATE )
|
if ( flags & OPEN_CREATE )
|
||||||
perm |= O_CREAT;
|
perm |= O_CREAT;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// actually open the file
|
// actually open the file
|
||||||
//
|
//
|
||||||
|
@ -169,6 +177,8 @@ void cFile::Open( const TSTRING& sFileName, uint32 flags )
|
||||||
{
|
{
|
||||||
throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) );
|
throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __AROS__
|
||||||
if( flags & OPEN_LOCKED_TEMP )
|
if( flags & OPEN_LOCKED_TEMP )
|
||||||
{
|
{
|
||||||
// unlink this file
|
// unlink this file
|
||||||
|
@ -176,9 +186,10 @@ void cFile::Open( const TSTRING& sFileName, uint32 flags )
|
||||||
{
|
{
|
||||||
// we weren't able to unlink file, so close handle and fail
|
// we weren't able to unlink file, so close handle and fail
|
||||||
close( fh );
|
close( fh );
|
||||||
throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) );
|
throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// turn the file handle into a FILE*
|
// turn the file handle into a FILE*
|
||||||
|
@ -369,3 +380,31 @@ void cFile::Truncate( File_t offset ) // throw(eFile)
|
||||||
throw( eFileTrunc( mpData->mFileName, iFSServices::GetInstance()->GetErrString() ) );
|
throw( eFileTrunc( mpData->mFileName, iFSServices::GetInstance()->GetErrString() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __AROS__
|
||||||
|
TSTRING cArosPath::AsPosix( const TSTRING& in )
|
||||||
|
{
|
||||||
|
if (in[0] == '/')
|
||||||
|
return in;
|
||||||
|
|
||||||
|
TSTRING out = '/' + in;
|
||||||
|
std::replace(out.begin(), out.end(), ':', '/');
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSTRING cArosPath::AsNative( const TSTRING& in )
|
||||||
|
{
|
||||||
|
if (in[0] != '/')
|
||||||
|
return in;
|
||||||
|
|
||||||
|
int x;
|
||||||
|
for (x=1; in[x] == '/' && x<in.length(); x++);
|
||||||
|
|
||||||
|
TSTRING out = in.substr(x);
|
||||||
|
TSTRING::size_type t = out.find_first_of('/');
|
||||||
|
out[t] = ':';
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "core/stdcore.h"
|
#include "core/stdcore.h"
|
||||||
#include "core/corestrings.h"
|
#include "core/corestrings.h"
|
||||||
|
#include "core/file.h"
|
||||||
|
|
||||||
#if !IS_UNIX //encase this all in an ifdef so it won't cause compile errors
|
#if !IS_UNIX //encase this all in an ifdef so it won't cause compile errors
|
||||||
#error Must be unix for unixfsservices
|
#error Must be unix for unixfsservices
|
||||||
|
@ -177,9 +178,15 @@ TCHAR cUnixFSServices::GetPathSeparator() const
|
||||||
return '/';
|
return '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __AROS__
|
||||||
void cUnixFSServices::ReadDir(const TSTRING& strFilename, std::vector<TSTRING> &v, bool bFullPaths) const throw(eFSServices)
|
void cUnixFSServices::ReadDir(const TSTRING& strFilename, std::vector<TSTRING> &v, bool bFullPaths) const throw(eFSServices)
|
||||||
{
|
{
|
||||||
|
#else
|
||||||
|
void cUnixFSServices::ReadDir(const TSTRING& strFilenameC, std::vector<TSTRING>& v, bool bFullPaths) const throw(eFSServices)
|
||||||
|
{
|
||||||
|
TSTRING strFilename = cArosPath::AsNative(strFilenameC);
|
||||||
|
#endif
|
||||||
|
|
||||||
//Get all the filenames
|
//Get all the filenames
|
||||||
DIR* dp;
|
DIR* dp;
|
||||||
dp = opendir( strFilename.c_str() );
|
dp = opendir( strFilename.c_str() );
|
||||||
|
@ -326,8 +333,14 @@ void cUnixFSServices::SetTempDirName(TSTRING& tmpPath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __AROS__
|
||||||
void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const throw(eFSServices)
|
void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const throw(eFSServices)
|
||||||
{
|
{
|
||||||
|
#else
|
||||||
|
void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const throw(eFSServices)
|
||||||
|
{
|
||||||
|
TSTRING strName = cArosPath::AsNative(strNameC);
|
||||||
|
#endif
|
||||||
//local variable for obtaining info on file.
|
//local variable for obtaining info on file.
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
|
|
||||||
#include "fsparserutil.h"
|
#include "fsparserutil.h"
|
||||||
#include "core/fsservices.h"
|
#include "core/fsservices.h"
|
||||||
|
#include "core/file.h"
|
||||||
#include "fspropset.h"
|
#include "fspropset.h"
|
||||||
#include "fsstrings.h"
|
#include "fsstrings.h"
|
||||||
#include "fco/fcopropvector.h"
|
#include "fco/fcopropvector.h"
|
||||||
|
@ -136,6 +137,10 @@ void cFSParserUtil::InterpretFCOName( const std::list<TSTRING>& l, cFCOName& nam
|
||||||
for( std::list<TSTRING>::const_iterator i = l.begin(); i != l.end(); i++ )
|
for( std::list<TSTRING>::const_iterator i = l.begin(); i != l.end(); i++ )
|
||||||
strT += *i;
|
strT += *i;
|
||||||
|
|
||||||
|
#ifdef __AROS__
|
||||||
|
strT = cArosPath::AsPosix(strT);
|
||||||
|
#endif
|
||||||
|
|
||||||
// let cFCOName handle interpretation
|
// let cFCOName handle interpretation
|
||||||
nameOut = strT;
|
nameOut = strT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,6 +304,12 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
|
||||||
|
|
||||||
// make sure it exists...
|
// make sure it exists...
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __AROS__
|
||||||
|
str = cArosPath::AsNative(str);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (access(str.c_str(), F_OK) != 0) {
|
if (access(str.c_str(), F_OK) != 0) {
|
||||||
TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY );
|
TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY );
|
||||||
TSTRING tmpStr = _T("Directory: ");
|
TSTRING tmpStr = _T("Directory: ");
|
||||||
|
|
Loading…
Reference in New Issue