#endif
#endif
-#ifdef __UNIX__
+#ifdef __OS2__
+// need to check for __OS2__ first since currently both
+// __OS2__ and __UNIX__ are defined.
+ #include <process.h>
+ #include "wx/os2/private.h"
+#ifdef __EMX__
+ #include <unistd.h>
+#endif
+#elif defined(__UNIX__)
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#endif
-#ifdef __WXPM__
- #include <process.h>
- #include "wx/os2/private.h"
-#endif
#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
#if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__) && !defined(__WXWINCE__)
#include <direct.h>
// No environment variables on WinCE
#ifndef __WXWINCE__
static const wxChar PATH_TOKS[] =
-#ifdef __WINDOWS__
+#if defined(__WINDOWS__) || defined(__OS2__)
/*
The space has been removed from the tokenizers, otherwise a
path such as "C:\Program Files" would be split into 2 paths:
{
wxString path2( node->GetData() );
if (
-#if defined(__WINDOWS__) || defined(__VMS__) || defined (__WXMAC__)
+#if defined(__WINDOWS__) || defined(__OS2__) || defined(__VMS__) || defined (__WXMAC__)
// Case INDEPENDENT
path.CompareTo (path2, wxString::ignoreCase) == 0
#else
if ((filename[0] == wxT('[') && filename[1] != wxT('.')))
return TRUE;
#endif
-#ifdef __WINDOWS__
+#if defined(__WINDOWS__) || defined(__OS2__)
// MSDOS like
if (filename[0] == wxT('\\') || (wxIsalpha (filename[0]) && filename[1] == wxT(':')))
return TRUE;
path[0] = SEP;
path[1] = wxT('\0');
}
-#ifdef __WXMSW__
+#if defined(__WXMSW__) || defined(__OS2__)
/* Check that path[2] is NULL! */
else if (path[1] == wxT(':') && !path[2])
{
#endif
// Handle User's home (ignore root homes!)
- size_t len;
+ size_t len = 0;
if ((val = wxGetUserHome (user)) != NULL &&
(len = wxStrlen(val)) > 2 &&
wxStrncmp(dest, val, len) == 0)
i --;
}
-#if defined(__WXMSW__) || defined(__WXPM__)
+#if defined(__WXMSW__) || defined(__OS2__)
// Try Drive specifier
if (wxIsalpha (buf[0]) && buf[1] == wxT(':'))
{
i --;
}
-#if defined(__WXMSW__) || defined(__WXPM__)
+#if defined(__WXMSW__) || defined(__OS2__)
// Try Drive specifier
if (wxIsalpha (buf[0]) && buf[1] == wxT(':'))
{
int i;
int j;
OSErr theErr;
- OSStatus theStatus;
+ OSStatus theStatus = noErr;
Boolean isDirectory = FALSE;
Str255 theParentPath = "\p";
FSSpec theParentSpec;
return wxMac2UnixFilename( wxMacFSSpec2MacFilename( spec) ) ;
}
-void wxUnixFilename2FSSpec( const char *path , FSSpec *spec )
+void wxUnixFilename2FSSpec( const wxChar *path , FSSpec *spec )
{
wxString var = wxUnix2MacFilename( path ) ;
wxMacFilename2FSSpec( var , spec ) ;
}
void
-#if defined(__WXMSW__) || defined(__WXPM__)
+#if defined(__WXMSW__) || defined(__OS2__)
wxUnix2DosFilename (wxChar *s)
#else
wxUnix2DosFilename (wxChar *WXUNUSED(s) )
#endif
{
// Yes, I really mean this to happen under DOS only! JACS
-#if defined(__WXMSW__) || defined(__WXPM__)
+#if defined(__WXMSW__) || defined(__OS2__)
if (s)
while (*s)
{
return FALSE;
}
-#elif defined(__WXPM__)
+#elif defined(__OS2__)
if ( ::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) != 0 )
return FALSE;
#else // !Win32
#if defined(__VISUALC__) \
|| defined(__BORLANDC__) \
|| defined(__WATCOMC__) \
+ || defined(__DMC__) \
|| defined(__GNUWIN32__)
int res = wxRemove(file);
#elif defined(__WXMAC__)
// assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
// for the GNU compiler
-#if (!(defined(__WXMSW__) || defined(__WXPM__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WINE__) || defined(__WXMICROWIN__)
+#if (!(defined(__WXMSW__) || defined(__OS2__) || defined(__DOS__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WINE__) || defined(__WXMICROWIN__)
#ifndef MSVCRT
if ( mkdir(wxFNCONV(dirname), perm) != 0 )
#else
if ( mkdir(wxFNCONV(dirname)) != 0 )
#endif
-#elif defined(__WXPM__)
+#elif defined(__OS2__)
if (::DosCreateDir((PSZ)dirname, NULL) != 0) // enhance for EAB's??
#elif defined(__DOS__)
#if defined(__WATCOMC__)
{
#ifdef __VMS__
return FALSE; //to be changed since rmdir exists in VMS7.x
-#elif defined(__WXPM__)
+#elif defined(__OS2__)
return (::DosDeleteDir((PSZ)dir.c_str()) == 0);
#else
{
wxString strPath(pszPathName);
-#ifdef __WINDOWS__
+#if defined(__WINDOWS__) || defined(__OS2__)
// Windows fails to find directory named "c:\dir\" even if "c:\dir" exists,
// so remove all trailing backslashes from the path - but don't do this for
// the pathes "d:\" (which are different from "d:") nor for just "\"
}
#endif // __WINDOWS__
+#ifdef __OS2__
+ // OS/2 can't handle "d:", it wants either "d:\" or "d:."
+ if (strPath.length() == 2 && strPath[1u] == _T(':'))
+ strPath << _T('.');
+#endif
+
#if defined(__WIN32__) && !defined(__WXMICROWIN__)
// stat() can't cope with network paths
DWORD ret = ::GetFileAttributes(strPath);
wxStructStat st;
#ifndef __VISAGECPP__
- return wxStat(pszPathName, &st) == 0 && ((st.st_mode & S_IFMT) == S_IFDIR);
+ return wxStat(strPath.c_str(), &st) == 0 && ((st.st_mode & S_IFMT) == S_IFDIR);
#else
// S_IFMT not supported in VA compilers.. st_mode is a 2byte value only
return wxStat(pszPathName, &st) == 0 && (st.st_mode == S_IFDIR);
{
ok = FALSE;
}
- #elif defined(__VISAGECPP__) || (defined (__OS2__) && defined (__WATCOMC__))
+ #elif defined(__OS2__)
APIRET rc;
- rc = ::DosQueryCurrentDir( 0 // current drive
- ,cbuf
- ,(PULONG)&sz
- );
- ok = rc != 0;
+ ULONG ulDriveNum = 0;
+ ULONG ulDriveMap = 0;
+ rc = ::DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap);
+ ok = rc == 0;
+ if (ok)
+ {
+ sz -= 3;
+ rc = ::DosQueryCurrentDir( 0 // current drive
+ ,cbuf + 3
+ ,(PULONG)&sz
+ );
+ cbuf[0] = 'A' + (ulDriveNum - 1);
+ cbuf[1] = ':';
+ cbuf[2] = '\\';
+ ok = rc == 0;
+ }
#else // !Win32/VC++ !Mac !OS2
ok = getcwd(cbuf, sz) != NULL;
#endif // platform
- #if wxUSE_UNICODE && !defined(__WXMAC__)
+ #if wxUSE_UNICODE && !(defined(__WXMAC__) && !defined(__DARWIN__))
// finally convert the result to Unicode if needed
wxConvFile.MB2WC(buf, cbuf, sz);
#endif // wxUSE_UNICODE
bool wxSetWorkingDirectory(const wxString& d)
{
-#if defined(__UNIX__) || defined(__WXMAC__) || defined(__DOS__)
- return (chdir(wxFNSTRINGCAST d.fn_str()) == 0);
-#elif defined(__WXPM__)
+#if defined(__OS2__)
return (::DosSetCurrentDir((PSZ)d.c_str()) == 0);
+#elif defined(__UNIX__) || defined(__WXMAC__) || defined(__DOS__)
+ return (chdir(wxFNSTRINGCAST d.fn_str()) == 0);
#elif defined(__WINDOWS__)
#ifdef __WIN32__