+ if ( FSGetVRefNum(&((*theVolRefs)[index]), &vRefNum) != noErr ) {
+ continue;
+ }
+ if ( FSGetVInfo(vRefNum, &volumeName, NULL, NULL) != noErr ) {
+ continue;
+ }
+ // get C string from Unicode HFS name
+ // see: http://developer.apple.com/carbon/tipsandtricks.html
+ CFStringRef cfstr = CFStringCreateWithCharacters( kCFAllocatorDefault,
+ volumeName.unicode,
+ volumeName.length );
+ // Do something with str
+ char *cstr = NewPtr(CFStringGetLength(cfstr) + 1);
+ if (( cstr == NULL ) ||
+ !CFStringGetCString(cfstr, cstr, CFStringGetLength(cfstr) + 1,
+ kCFStringEncodingMacRoman))
+ {
+ CFRelease( cstr );
+ continue;
+ }
+ wxString name( cstr );
+ DisposePtr( cstr );
+ CFRelease( cfstr );
+
+ GetVolParmsInfoBuffer volParmsInfo;
+ UInt32 actualSize;
+ if ( FSGetVolParms(vRefNum, sizeof(volParmsInfo), &volParmsInfo, &actualSize) != noErr ) {
+ continue;
+ }
+
+ paths.Add(path);
+ names.Add(name);
+
+ if ( VolIsEjectable(&volParmsInfo) )
+ icon_ids.Add(wxFileIconsTable::cdrom);
+ else
+ icon_ids.Add(wxFileIconsTable::drive);
+ }
+ ::HUnlock( (Handle)theVolRefs );
+ ::DisposeHandle( (Handle)theVolRefs );
+ }
+#else // !__DARWIN__
+ FSSpec volume;
+ short index = 1;
+ while(1)
+ {
+ short actualCount = 0 ;
+ if (OnLine(&volume, 1, &actualCount, &index ) != noErr || actualCount==0)
+ {
+ break;
+ }
+
+ wxString name = wxMacFSSpec2MacFilename( &volume );
+ paths.Add(name + wxFILE_SEP_PATH);
+ names.Add(name);
+ icon_ids.Add(wxFileIconsTable::drive);
+ }
+#endif // __DARWIN__
+
+#elif defined(__UNIX__)
+ paths.Add(wxT("/"));
+ names.Add(wxT("/"));
+ icon_ids.Add(wxFileIconsTable::computer);
+#else
+ #error "Unsupported platform in wxGenericDirCtrl!"
+#endif
+ return paths.GetCount();
+}
+
+// ----------------------------------------------------------------------------
+// wxIsDriveAvailable
+// ----------------------------------------------------------------------------
+
+#if defined(__DOS__)
+
+bool wxIsDriveAvailable(const wxString& dirName)
+{
+ // FIXME_MGL - this method leads to hang up under Watcom for some reason
+#ifndef __WATCOMC__
+ if ( dirName.Len() == 3 && dirName[1u] == wxT(':') )
+ {
+ wxString dirNameLower(dirName.Lower());
+ // VS: always return TRUE for removable media, since Win95 doesn't
+ // like it when MS-DOS app accesses empty floppy drive
+ return (dirNameLower[0u] == wxT('a') ||
+ dirNameLower[0u] == wxT('b') ||
+ wxPathExists(dirNameLower));
+ }
+ else
+#endif
+ return TRUE;
+}
+
+#elif defined(__WINDOWS__) || defined(__WXPM__)