- SFSaveDisk = 0x214, CurDirStore = 0x398
- };
- FSSpec cwdSpec ;
-
- FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
- wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
- strcpy( buf , res ) ;
- if (0) {
-#else
- if (getcwd(cbuf, sz) == NULL) {
-#endif
- delete [] cbuf;
-#else // wxUnicode
-#ifdef _MSC_VER
- if (_getcwd(buf, sz) == NULL) {
-#elif defined(__WXMAC__) && !defined(__DARWIN__)
- FSSpec cwdSpec ;
- FCBPBRec pb;
- OSErr error;
- Str255 fileName ;
- pb.ioNamePtr = (StringPtr) &fileName;
- pb.ioVRefNum = 0;
- pb.ioRefNum = LMGetCurApRefNum();
- pb.ioFCBIndx = 0;
- error = PBGetFCBInfoSync(&pb);
- if ( error == noErr )
+ buf = new wxChar[sz + 1];
+ }
+
+ bool ok = FALSE;
+
+ // for the compilers which have Unicode version of _getcwd(), call it
+ // directly, for the others call the ANSI version and do the translation
+#if !wxUSE_UNICODE
+ #define cbuf buf
+#else // wxUSE_UNICODE
+ bool needsANSI = TRUE;
+
+ #if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU
+ wxCharBuffer c_buffer(sz);
+ char *cbuf = (char*)(const char*)c_buffer;
+ #endif
+
+ #ifdef HAVE_WGETCWD
+ #if wxUSE_UNICODE_MSLU
+ if ( wxGetOsVersion() != wxWIN95 )
+ #endif
+ {
+ ok = _wgetcwd(buf, sz) != NULL;
+ needsANSI = FALSE;
+ }
+ #endif
+
+ if ( needsANSI )
+#endif // wxUSE_UNICODE
+ {
+ #ifdef _MSC_VER
+ ok = _getcwd(cbuf, sz) != NULL;
+ #elif defined(__WXMAC__) && !defined(__DARWIN__)
+ FSSpec cwdSpec ;
+ FCBPBRec pb;
+ OSErr error;
+ Str255 fileName ;
+ pb.ioNamePtr = (StringPtr) &fileName;
+ pb.ioVRefNum = 0;
+ pb.ioRefNum = LMGetCurApRefNum();
+ pb.ioFCBIndx = 0;
+ error = PBGetFCBInfoSync(&pb);
+ if ( error == noErr )
+ {
+ cwdSpec.vRefNum = pb.ioFCBVRefNum;
+ cwdSpec.parID = pb.ioFCBParID;
+ cwdSpec.name[0] = 0 ;
+ wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ;
+
+ strcpy( cbuf , res ) ;
+ cbuf[res.length()]=0 ;
+
+ ok = TRUE;
+ }
+ else
+ {
+ ok = FALSE;
+ }
+ #elif defined(__VISAGECPP__) || (defined (__OS2__) && defined (__WATCOMC__))
+ APIRET rc;
+ rc = ::DosQueryCurrentDir( 0 // current drive
+ ,cbuf
+ ,(PULONG)&sz
+ );
+ ok = rc != 0;
+ #else // !Win32/VC++ !Mac !OS2
+ ok = getcwd(cbuf, sz) != NULL;
+ #endif // platform
+ }
+
+ if ( !ok )