+ #ifdef HAVE_WGETCWD
+ ok = _wgetcwd(buf, sz) != NULL;
+ #else // !HAVE_WGETCWD
+ wxCharBuffer cbuf(sz);
+ #endif
+#endif //
+
+#if !wxUSE_UNICODE || !defined(HAVE_WGETCWD)
+ #ifdef _MSC_VER
+ ok = _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 )
+ {
+ cwdSpec.vRefNum = pb.ioFCBVRefNum;
+ cwdSpec.parID = pb.ioFCBParID;
+ cwdSpec.name[0] = 0 ;
+ wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ;
+
+ strcpy( buf , res ) ;
+ buf[res.length()]=0 ;
+
+ ok = TRUE;
+ }
+ else
+ {
+ ok = FALSE;
+ }
+ #elif defined(__VISAGECPP__) || (defined (__OS2__) && defined (__WATCOMC__))
+ APIRET rc;
+ rc = ::DosQueryCurrentDir( 0 // current drive
+ ,buf
+ ,(PULONG)&sz
+ );
+ ok = rc != 0;
+ #else // !Win32/VC++ !Mac !OS2
+ ok = getcwd(buf, sz) != NULL;
+ #endif // platform
+#endif // !wxUSE_UNICODE || !HAVE_WGETCWD
+
+ if ( !ok )
+ {
+ wxLogSysError(_("Failed to get the working directory"));