#endif
#endif
-#ifdef __GNUWIN32__
- #include <wchar.h>
- #ifndef __TWIN32__
- #include <sys/unistd.h>
- #endif
-#endif
-
#ifdef __BORLANDC__ // Please someone tell me which version of Borland needs
// this (3.1 I believe) and how to test for it.
// If this works for Borland 4.0 as well, then no worries.
#ifdef __WINDOWS__
#include <windows.h>
-#endif
+
+ // sys/cygwin.h is needed for cygwin_conv_to_full_win32_path()
+ //
+ // note that it must be included after <windows.h>
+ #ifdef __GNUWIN32__
+ #ifdef __CYGWIN__
+ #include <sys/cygwin.h>
+ #endif
+ #include <wchar.h>
+ #ifndef __TWIN32__
+ #include <sys/unistd.h>
+ #endif
+ #endif // __GNUWIN32__
+#endif // __WINDOWS__
// TODO: Borland probably has _wgetcwd as well?
#ifdef _MSC_VER
#define _MAXPATHLEN 1024
#endif
-extern wxChar *wxBuffer;
-
#ifdef __WXMAC__
# include "MoreFiles.h"
# include "MoreFilesExtras.h"
bool
wxFileExists (const wxString& filename)
{
-#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
- // GetFileAttributes can copy with network paths
- DWORD ret = GetFileAttributes(filename);
- DWORD isDir = (ret & FILE_ATTRIBUTE_DIRECTORY);
- return ((ret != 0xffffffff) && (isDir == 0));
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
+ // GetFileAttributes can copy with network paths unlike stat()
+ DWORD ret = ::GetFileAttributes(filename);
+
+ return (ret != (DWORD)-1) && !(ret & FILE_ATTRIBUTE_DIRECTORY);
#else
wxStructStat stbuf;
if ( !filename.empty() && wxStat (OS_FILENAME(filename), &stbuf) == 0 )
#if defined(__WXMAC__) && !defined(__DARWIN__)
// Classic or Carbon CodeWarrior like
// Carbon with Apple DevTools is Unix like
-
+
// This seems wrong to me, but there is no fix. since
// "MacOS:MyText.txt" is absolute whereas "MyDir:MyText.txt"
// is not. Or maybe ":MyDir:MyText.txt" has to be used? RR.
if (path)
{
register wxChar *tcp;
-
+
tcp = path + wxStrlen (path);
while (--tcp >= path)
{
{
wxChar *path = WXSTRINGCAST path1 ;
register wxChar *tcp;
-
+
tcp = path + wxStrlen (path);
while (--tcp >= path)
{
if (path && *path)
{
static wxChar buf[_MAXPATHLEN];
-
+
// Local copy
wxStrcpy (buf, path);
-
+
int l = wxStrlen(path);
int i = l - 1;
-
+
// Search backward for a backward or forward slash
while (i > -1)
{
#endif
i --;
}
-
+
#if defined(__WXMSW__) || defined(__WXPM__)
// Try Drive specifier
if (wxIsalpha (buf[0]) && buf[1] == wxT(':'))
if (path != wxT(""))
{
wxChar buf[_MAXPATHLEN];
-
+
// Local copy
wxStrcpy (buf, WXSTRINGCAST path);
-
+
int l = path.Length();
int i = l - 1;
#endif
i --;
}
-
+
#if defined(__WXMSW__) || defined(__WXPM__)
// Try Drive specifier
if (wxIsalpha (buf[0]) && buf[1] == wxT(':'))
(void) FSpMakeFSRef( spec, &theRef );
// get the POSIX path associated with the FSRef
(void) FSRefMakePath( &theRef, (UInt8 *)thePath, sizeof(thePath) );
-
+
// create path string for return value
wxString result( thePath ) ;
#else
(*myPath)[length] = 0 ;
if ((length > 0) && ((*myPath)[length-1] == ':'))
(*myPath)[length-1] = 0 ;
-
+
// create path string for return value
wxString result( (char*) *myPath ) ;
*s = '.' ;
else
*s = '/' ;
-
+
while (*s)
{
if (*s == ':')
bool wxPathExists(const wxChar *pszPathName)
{
wxString strPath(pszPathName);
+
#ifdef __WINDOWS__
// 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
}
#endif // __WINDOWS__
-#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
- // Stat can't cope with network paths
- DWORD ret = GetFileAttributes(strPath.c_str());
- DWORD isDir = (ret & FILE_ATTRIBUTE_DIRECTORY);
- return ((ret != 0xffffffff) && (isDir != 0));
-#else
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
+ // stat() can't cope with network paths
+ DWORD ret = ::GetFileAttributes(strPath);
+
+ return (ret != (DWORD)-1) && (ret & FILE_ATTRIBUTE_DIRECTORY);
+#else // !__WIN32__
wxStructStat st;
#ifndef __VISAGECPP__
(st.st_mode == S_IFDIR);
#endif
-#endif
+#endif // __WIN32__/!__WIN32__
}
// Get a temporary filename, opening and closing the file.
if (gs_dir)
delete gs_dir;
gs_dir = new wxDir(gs_dirPath);
-
+
if ( !gs_dir->IsOpened() )
{
wxLogSysError(_("Can not enumerate files '%s'"), spec);
return wxEmptyString;
}
-
+
int dirFlags = 0;
switch (flags)
{
case wxFILE: dirFlags = wxDIR_FILES; break;
default: dirFlags = wxDIR_DIRS | wxDIR_FILES; break;
}
-
+
wxString result;
gs_dir->GetFirst(&result, wxFileNameFromPath(spec), dirFlags);
if ( result.IsEmpty() )
wxString result;
gs_dir->GetNext(&result);
-
+
if ( result.IsEmpty() )
{
wxDELETE(gs_dir);
return result;
}
-
+
return gs_dirPath + result;
}
}
#endif // __DJGPP__
-#ifdef __CYGWIN10__
- // another example of DOS/Unix mix
+#ifdef __CYGWIN__
+ // another example of DOS/Unix mix (Cygwin)
wxString pathUnix = buf;
cygwin_conv_to_full_win32_path(pathUnix, buf);
-#endif // __CYGWIN10__
+#endif // __CYGWIN__
// finally convert the result to Unicode if needed
#if wxUSE_UNICODE && !defined(HAVE_WGETCWD)