const CString os2FullDir(const CString& name) { char drive = ' '; if (name.length() > 1 && name[2] == ':') { drive = name[1]; } else { drive = queryCurrentDisk(); } CString oldDir = queryCurrentDir(drive), newDir; if (oldDir != "") { DosSetCurrentDir((PSZ)(CPCHAR)name); newDir = queryCurrentDir(drive); DosSetCurrentDir((PSZ)(CPCHAR)oldDir); return nativePathName(newDir); } return ""; }
std::string PathName::GetNativePathName(void) const { #if defined(WIN32) // windows // replace all / with \ . // std::string::size_type i = 0; std::string nativePathName(this->GetPathName()); while ((i = nativePathName.find('/', i)) != std::string::npos) { nativePathName[i] = '\\'; } return nativePathName; #else /// POSIX UNIX return this->GetPathName(); #endif }
const CString queryCurrentDir(char drive) { char tmp[256]; if (drive == 0) drive = queryCurrentDisk(); else drive = toupper(drive); ULONG size = sizeof(tmp); ULONG driveNo; driveNo = (drive - 'A')+1; *tmp = '\0'; if (DosQueryCurrentDir(driveNo, (PSZ)tmp, &size) != 0) { return ""; } return nativePathName(CString(drive) + ":" + pathSeparator() + tmp); }