#include <process.h>
#include "wx/os2/private.h"
#endif
-#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
+#if defined(__WINDOWS__) && !defined(__WXMICROWIN__) && !defined(__WXWINE__)
#if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__)
#include <direct.h>
#include <dos.h>
return result ;
}
+#ifndef __DARWIN__
+// Mac file names are POSIX (Unix style) under Darwin
+// therefore the conversion functions below are not needed
+
+static char sMacFileNameConversion[ 1000 ] ;
+#endif
void wxMacFilename2FSSpec( const char *path , FSSpec *spec )
{
+ OSStatus err = noErr ;
#ifdef __DARWIN__
FSRef theRef;
// get the FSRef associated with the POSIX path
- (void) FSPathMakeRef((const UInt8 *) path, &theRef, NULL);
+ err = FSPathMakeRef((const UInt8 *) path, &theRef, NULL);
// convert the FSRef to an FSSpec
- (void) FSGetCatalogInfo(&theRef, kFSCatInfoNone, NULL, NULL, spec, NULL);
+ err = FSGetCatalogInfo(&theRef, kFSCatInfoNone, NULL, NULL, spec, NULL);
#else
- FSpLocationFromFullPath( strlen(path) , path , spec ) ;
+ if ( strchr( path , ':' ) == NULL )
+ {
+ // try whether it is a volume / or a mounted volume
+ strncpy( sMacFileNameConversion , path , 1000 ) ;
+ sMacFileNameConversion[998] = 0 ;
+ strcat( sMacFileNameConversion , ":" ) ;
+ err = FSpLocationFromFullPath( strlen(sMacFileNameConversion) , sMacFileNameConversion , spec ) ;
+ }
+ else
+ {
+ err = FSpLocationFromFullPath( strlen(path) , path , spec ) ;
+ }
#endif
}
#ifndef __DARWIN__
-// Mac file names are POSIX (Unix style) under Darwin
-// therefore the conversion functions below are not needed
-
-static char sMacFileNameConversion[ 1000 ] ;
wxString wxMac2UnixFilename (const char *str)
{
if ( ::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) != 0 )
return FALSE;
#else // !Win32
- wxStructStat fbuf;
+ wxStructStat fbuf;
// get permissions of file1
- if ( wxStat( file1, &fbuf) != 0 )
+ if ( wxStat( file1.c_str(), &fbuf) != 0 )
{
// the file probably doesn't exist or we haven't the rights to read
// from it anyhow
// create file2 with the same permissions than file1 and open it for
// writing
+
wxFile fileOut;
if ( !fileOut.Create(file2, overwrite, fbuf.st_mode & 0777) )
return FALSE;
bool needsANSI = TRUE;
#if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU
- wxCharBuffer c_buffer(sz);
- char *cbuf = (char*)(const char*)c_buffer;
+ // This is not legal code as the compiler
+ // is allowed destroy the wxCharBuffer.
+ // wxCharBuffer c_buffer(sz);
+ // char *cbuf = (char*)(const char*)c_buffer;
+ char cbuf[_MAXPATHLEN];
#endif
#ifdef HAVE_WGETCWD
wxString wxGetCwd()
{
- wxString str;
-
- // we can't create wxStringBuffer object inline: Sun CC generates buggy
- // code in this case!
- {
- wxStringBuffer buf(str, _MAXPATHLEN);
- wxGetWorkingDirectory(buf, _MAXPATHLEN);
- }
-
+ wxChar *buffer = new wxChar[_MAXPATHLEN];
+ wxGetWorkingDirectory(buffer, _MAXPATHLEN);
+ wxString str( buffer );
+ delete [] buffer;
+
return str;
}