git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24647
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
#elif defined(__WXMSW__) && defined(__WXWINCE__)
// TODO: what to include?
#elif defined(__WXMSW__) && defined(__WXWINCE__)
// TODO: what to include?
+#elif (defined(__OS2__))
+ #include <io.h>
#elif (defined(__UNIX__) || defined(__GNUWIN32__))
#include <unistd.h>
#include <time.h>
#elif (defined(__UNIX__) || defined(__GNUWIN32__))
#include <unistd.h>
#include <time.h>
#else
#error "Please specify the header with file functions declarations."
#endif
#else
#error "Please specify the header with file functions declarations."
#endif
-#elif (defined(__WXPM__))
- #include <io.h>
#elif (defined(__WXSTUBS__))
// Have to ifdef this for different environments
#include <io.h>
#elif (defined(__WXSTUBS__))
// Have to ifdef this for different environments
#include <io.h>
if ( chmod( (const char*) m_strTemp.fn_str(), mode) == -1 )
{
if ( chmod( (const char*) m_strTemp.fn_str(), mode) == -1 )
{
wxLogSysError(_("Failed to set temporary file permissions"));
wxLogSysError(_("Failed to set temporary file permissions"));
+#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
#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>
#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[] =
// No environment variables on WinCE
#ifndef __WXWINCE__
static const wxChar PATH_TOKS[] =
+#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:
/*
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 (
{
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
// Case INDEPENDENT
path.CompareTo (path2, wxString::ignoreCase) == 0
#else
if ((filename[0] == wxT('[') && filename[1] != wxT('.')))
return TRUE;
#endif
if ((filename[0] == wxT('[') && filename[1] != wxT('.')))
return TRUE;
#endif
+#if defined(__WINDOWS__) || defined(__OS2__)
// MSDOS like
if (filename[0] == wxT('\\') || (wxIsalpha (filename[0]) && filename[1] == wxT(':')))
return TRUE;
// MSDOS like
if (filename[0] == wxT('\\') || (wxIsalpha (filename[0]) && filename[1] == wxT(':')))
return TRUE;
path[0] = SEP;
path[1] = wxT('\0');
}
path[0] = SEP;
path[1] = wxT('\0');
}
+#if defined(__WXMSW__) || defined(__OS2__)
/* Check that path[2] is NULL! */
else if (path[1] == wxT(':') && !path[2])
{
/* Check that path[2] is NULL! */
else if (path[1] == wxT(':') && !path[2])
{
-#if defined(__WXMSW__) || defined(__WXPM__)
+#if defined(__WXMSW__) || defined(__OS2__)
// Try Drive specifier
if (wxIsalpha (buf[0]) && buf[1] == wxT(':'))
{
// Try Drive specifier
if (wxIsalpha (buf[0]) && buf[1] == wxT(':'))
{
-#if defined(__WXMSW__) || defined(__WXPM__)
+#if defined(__WXMSW__) || defined(__OS2__)
// Try Drive specifier
if (wxIsalpha (buf[0]) && buf[1] == wxT(':'))
{
// Try Drive specifier
if (wxIsalpha (buf[0]) && buf[1] == wxT(':'))
{
-#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
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 ( ::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) != 0 )
return FALSE;
#else // !Win32
if ( ::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) != 0 )
return FALSE;
#else // !Win32
// assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
// for the GNU compiler
// 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
#ifndef MSVCRT
if ( mkdir(wxFNCONV(dirname), perm) != 0 )
#else
if ( mkdir(wxFNCONV(dirname)) != 0 )
#endif
if (::DosCreateDir((PSZ)dirname, NULL) != 0) // enhance for EAB's??
#elif defined(__DOS__)
#if defined(__WATCOMC__)
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
{
#ifdef __VMS__
return FALSE; //to be changed since rmdir exists in VMS7.x
return (::DosDeleteDir((PSZ)dir.c_str()) == 0);
#else
return (::DosDeleteDir((PSZ)dir.c_str()) == 0);
#else
{
wxString strPath(pszPathName);
{
wxString strPath(pszPathName);
+#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 "\"
// 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 "\"
+#ifdef __OS2__
+ // OS/2 can't handle "d:", it wants either "d:\" or "d:."
+ if (strPath.length() == 2 && strPath[1] == _T(':'))
+ strPath << _T('.');
+#endif
+
#if defined(__WIN32__) && !defined(__WXMICROWIN__)
// stat() can't cope with network paths
DWORD ret = ::GetFileAttributes(strPath);
#if defined(__WIN32__) && !defined(__WXMICROWIN__)
// stat() can't cope with network paths
DWORD ret = ::GetFileAttributes(strPath);
wxStructStat st;
#ifndef __VISAGECPP__
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);
#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);
- #elif defined(__VISAGECPP__) || (defined (__OS2__) && defined (__WATCOMC__))
- 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
#else // !Win32/VC++ !Mac !OS2
ok = getcwd(cbuf, sz) != NULL;
#endif // platform
bool wxSetWorkingDirectory(const wxString& d)
{
bool wxSetWorkingDirectory(const wxString& d)
{
-#if defined(__UNIX__) || defined(__WXMAC__) || defined(__DOS__)
- return (chdir(wxFNSTRINGCAST d.fn_str()) == 0);
-#elif defined(__WXPM__)
return (::DosSetCurrentDir((PSZ)d.c_str()) == 0);
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__
#elif defined(__WINDOWS__)
#ifdef __WIN32__
-#elif defined(__WXPM__)
- // for now just create a file
- //
- // future enhancements can be to set some extended attributes for file
- // systems OS/2 supports that have them (HPFS, FAT32) and security
- // (HPFS386)
- static const wxChar *szMktempSuffix = wxT("XXX");
- path << dir << _T('/') << name << szMktempSuffix;
-
- // Temporarily remove - MN
- #ifndef __WATCOMC__
- ::DosCreateDir(wxStringBuffer(path, MAX_PATH), NULL);
- #endif
-
-#else // !Windows, !OS/2
if ( dir.empty() )
{
#if defined(__WXMAC__) && !defined(__DARWIN__)
if ( dir.empty() )
{
#if defined(__WXMAC__) && !defined(__DARWIN__)
if ( dir.empty() )
{
// default
if ( dir.empty() )
{
// default
+ #if defined(__DOS__) || defined(__OS2__)
dir = _T(".");
#else
dir = _T("/tmp");
dir = _T(".");
#else
dir = _T("/tmp");
{
if (format == wxPATH_NATIVE)
{
{
if (format == wxPATH_NATIVE)
{
-#if defined(__WXMSW__) || defined(__WXPM__) || defined(__DOS__)
+#if defined(__WXMSW__) || defined(__OS2__) || defined(__DOS__)
format = wxPATH_DOS;
#elif defined(__WXMAC__) && !defined(__DARWIN__)
format = wxPATH_MAC;
format = wxPATH_DOS;
#elif defined(__WXMAC__) && !defined(__DARWIN__)
format = wxPATH_MAC;