Support native-style paths on DOS/DJGPP

This commit is contained in:
Brian Cox 2016-06-29 21:02:12 -07:00
parent c18af8953c
commit 0d8bdcc4d8
10 changed files with 45 additions and 20 deletions

View File

@ -87,6 +87,9 @@
/* Define to 1 if you have the <sys/param.h> header file. */ /* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H #undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define to 1 if you have the <sys/socket.h> header file. */ /* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H #undef HAVE_SYS_SOCKET_H

2
configure vendored
View File

@ -5694,7 +5694,7 @@ fi
done done
for ac_header in unistd.h syslog.h langinfo.h sys/statfs.h for ac_header in unistd.h syslog.h langinfo.h sys/statfs.h sys/select.h
do : do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"

View File

@ -68,7 +68,7 @@ AC_CHECK_HEADERS(sys/mount.h,,,
#endif #endif
]]) ]])
AC_CHECK_HEADERS(sys/ustat.h sys/sysmacros.h sys/syslog.h sys/socket.h) AC_CHECK_HEADERS(sys/ustat.h sys/sysmacros.h sys/syslog.h sys/socket.h)
AC_CHECK_HEADERS(unistd.h syslog.h langinfo.h sys/statfs.h) AC_CHECK_HEADERS(unistd.h syslog.h langinfo.h sys/statfs.h sys/select.h)
AC_CHECK_HEADERS(signum.h bits/signum.h, break ) AC_CHECK_HEADERS(signum.h bits/signum.h, break )
AC_CHECK_HEADERS(stdarg.h varargs.h, break ) AC_CHECK_HEADERS(stdarg.h varargs.h, break )

View File

@ -143,8 +143,8 @@ public:
}; };
#if IS_AROS #if USES_DEVICE_PATH
class cArosPath class cDevicePath
{ {
public: public:
static TSTRING AsPosix(const TSTRING& in); static TSTRING AsPosix(const TSTRING& in);

View File

@ -143,13 +143,13 @@ cFile::~cFile()
// Open // Open
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifndef __AROS #if !USES_DEVICE_PATH
void cFile::Open( const TSTRING& sFileName, uint32 flags ) void cFile::Open( const TSTRING& sFileName, uint32 flags )
{ {
#else #else
void cFile::Open( const TSTRING& sFileNameC, uint32 flags ) void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
{ {
TSTRING sFileName = cArosPath::AsNative(sFileNameC); TSTRING sFileName = cDevicePath::AsNative(sFileNameC);
#endif #endif
mode_t openmode = 0664; mode_t openmode = 0664;
if (mpData->mpCurrStream != NULL) if (mpData->mpCurrStream != NULL)
@ -458,30 +458,51 @@ void cFile::Truncate( File_t offset ) // throw(eFile)
} }
#if IS_AROS #if USES_DEVICE_PATH
TSTRING cArosPath::AsPosix( const TSTRING& in ) // For paths of type DH0:/dir/file
TSTRING cDevicePath::AsPosix( const TSTRING& in )
{ {
if (in[0] == '/') if (in[0] == '/')
return in; return in;
#if IS_DOS_DJGPP
TSTRING out = "/dev/" + in;
std::replace(out.begin(), out.end(), '\\', '/');
#else
TSTRING out = '/' + in; TSTRING out = '/' + in;
#endif
std::replace(out.begin(), out.end(), ':', '/'); std::replace(out.begin(), out.end(), ':', '/');
return out; return out;
} }
TSTRING cArosPath::AsNative( const TSTRING& in ) TSTRING cDevicePath::AsNative( const TSTRING& in )
{ {
if (in[0] != '/') if (in[0] != '/')
return in; return in;
int x; #if IS_DOS_DJGPP
for (x=1; in[x] == '/' && x<in.length(); x++); if (in.find("/dev") != 0 || in.length() < 6)
return in;
TSTRING out = "?:/";
out[0] = in[5];
if (in.length() >= 8)
out.append(in.substr(7));
return out;
#elif IS_AROS
int x = 1;
for ( x; in[x] == '/' && x<in.length(); x++);
TSTRING out = in.substr(x); TSTRING out = in.substr(x);
TSTRING::size_type t = out.find_first_of('/'); TSTRING::size_type t = out.find_first_of('/');
out[t] = ':'; out[t] = ':';
return out; return out;
#endif
} }
#endif #endif

View File

@ -299,6 +299,7 @@
#define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS) #define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS)
#define NEEDS_SWAB_IMPL (IS_SYLLABLE || IS_ANDROID || IS_SORTIX) #define NEEDS_SWAB_IMPL (IS_SYLLABLE || IS_ANDROID || IS_SORTIX)
#define USES_MBLEN (!IS_ANDROID && !IS_AROS) #define USES_MBLEN (!IS_ANDROID && !IS_AROS)
#define USES_DEVICE_PATH (IS_AROS || IS_DOS_DJGPP)
#define ICONV_CONST_SOURCE (IS_MINIX) #define ICONV_CONST_SOURCE (IS_MINIX)

View File

@ -178,13 +178,13 @@ TCHAR cUnixFSServices::GetPathSeparator() const
return '/'; return '/';
} }
#if !IS_AROS #if !USES_DEVICE_PATH
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 #else
void cUnixFSServices::ReadDir(const TSTRING& strFilenameC, std::vector<TSTRING>& v, bool bFullPaths) const throw(eFSServices) void cUnixFSServices::ReadDir(const TSTRING& strFilenameC, std::vector<TSTRING>& v, bool bFullPaths) const throw(eFSServices)
{ {
TSTRING strFilename = cArosPath::AsNative(strFilenameC); TSTRING strFilename = cDevicePath::AsNative(strFilenameC);
#endif #endif
//Get all the filenames //Get all the filenames
@ -326,13 +326,13 @@ void cUnixFSServices::SetTempDirName(TSTRING& tmpPath) {
} }
#if !IS_AROS #if !USES_DEVICE_PATH
void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const throw(eFSServices) void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const throw(eFSServices)
{ {
#else #else
void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const throw(eFSServices) void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const throw(eFSServices)
{ {
TSTRING strName = cArosPath::AsNative(strNameC); TSTRING strName = cDevicePath::AsNative(strNameC);
#endif #endif
//local variable for obtaining info on file. //local variable for obtaining info on file.
struct stat statbuf; struct stat statbuf;

View File

@ -137,8 +137,8 @@ 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;
#if IS_AROS #if USES_DEVICE_PATH
strT = cArosPath::AsPosix(strT); strT = cDevicePath::AsPosix(strT);
#endif #endif
// let cFCOName handle interpretation // let cFCOName handle interpretation

View File

@ -56,7 +56,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#if !IS_SORTIX #if HAVE_SYS_SELECT_H
# include <sys/select.h> # include <sys/select.h>
#endif #endif

View File

@ -311,8 +311,8 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
// make sure it exists... // make sure it exists...
// //
#if IS_AROS #if USES_DEVICE_PATH
temp_directory = cArosPath::AsNative(temp_directory); temp_directory = cDevicePath::AsNative(temp_directory);
#endif #endif
if (access(temp_directory.c_str(), F_OK) != 0) { if (access(temp_directory.c_str(), F_OK) != 0) {