bool wxIsDriveAvailable(const wxString& WXUNUSED_IN_WINCE(dirName)) { #ifdef __WXWINCE__ return false; #else #ifdef __WIN32__ UINT errorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); #endif bool success = true; // Check if this is a root directory and if so, // whether the drive is available. if (dirName.length() == 3 && dirName[(size_t)1] == wxT(':')) { wxString dirNameLower(dirName.Lower()); #if defined(__GNUWIN32__) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1) success = wxDirExists(dirNameLower); #else #if defined(__OS2__) // Avoid changing to drive since no media may be inserted. if (dirNameLower[(size_t)0] == 'a' || dirNameLower[(size_t)0] == 'b') return success; #endif int currentDrive = _getdrive(); int thisDrive = (int) (dirNameLower[(size_t)0] - 'a' + 1) ; int err = setdrive( thisDrive ) ; setdrive( currentDrive ); if (err == -1) { success = false; } #endif } #ifdef __WIN32__ (void) SetErrorMode(errorMode); #endif return success; #endif }
bool WEXPORT WFileName::makeDir() const { splitpath( *this, _x.drive, _x.dir, _x.fname, _x.ext, PATHSEP_STR ); if( strlen( _x.dir ) > 0 ) { unsigned olddrive; if( setdrive( _x.drive, &olddrive ) ) { int ret = mkdir( _x.dir ); unsigned total; _dos_setdrive( olddrive, &total ); return( ret == 0 ); } return( false ); } return( true ); }
bool WEXPORT WFileName::setCWD() const { splitpath( *this, _x.drive, _x.dir, _x.fname, _x.ext, PATHSEP_STR ); unsigned olddrive; if( setdrive( _x.drive, &olddrive ) ) { if( strlen( _x.dir ) > 0 ) { int ret = chdir( _x.dir ); if( ret == 0 ) { return TRUE; } unsigned total; _dos_setdrive( olddrive, &total ); return FALSE; } return TRUE; } return FALSE; }