+ wxChar buf[_MAXPATHLEN];
+
+ // Local copy
+ wxStrcpy (buf, WXSTRINGCAST path);
+
+ int l = path.Length();
+ int i = l - 1;
+
+ // Search backward for a backward or forward slash
+ while (i > -1)
+ {
+#if defined(__WXMAC__) && !defined(__DARWIN__)
+ // Classic or Carbon CodeWarrior like
+ // Carbon with Apple DevTools is Unix like
+ if (path[i] == wxT(':') )
+ {
+ buf[i] = 0;
+ return wxString(buf);
+ }
+#else
+ // Unix like or Windows
+ if (path[i] == wxT('/') || path[i] == wxT('\\'))
+ {
+ buf[i] = 0;
+ return wxString(buf);
+ }
+#endif
+#ifdef __VMS__
+ if (path[i] == wxT(']'))
+ {
+ buf[i+1] = 0;
+ return wxString(buf);
+ }
+#endif
+ i --;
+ }
+
+#if defined(__WXMSW__) || defined(__WXPM__)
+ // Try Drive specifier
+ if (wxIsalpha (buf[0]) && buf[1] == wxT(':'))
+ {
+ // A:junk --> A:. (since A:.\junk Not A:\junk)
+ buf[2] = wxT('.');
+ buf[3] = wxT('\0');
+ return wxString(buf);
+ }
+#endif
+ }
+ return wxString(wxT(""));
+}
+
+// Utility for converting delimiters in DOS filenames to UNIX style
+// and back again - or we get nasty problems with delimiters.
+// Also, convert to lower case, since case is significant in UNIX.
+
+#if defined(__WXMAC__)
+wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
+{
+#ifdef __DARWIN__
+ FSRef theRef;
+ char thePath[FILENAME_MAX];
+
+ // convert the FSSpec to an FSRef
+ (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
+ Handle myPath ;
+ short length ;
+
+ // get length of path and allocate handle
+ FSpGetFullPath( spec , &length , &myPath ) ;
+ ::SetHandleSize( myPath , length + 1 ) ;
+ ::HLock( myPath ) ;
+ (*myPath)[length] = 0 ;
+ if ((length > 0) && ((*myPath)[length-1] == ':'))
+ (*myPath)[length-1] = 0 ;
+
+ // create path string for return value
+ wxString result( (char*) *myPath ) ;