int chdir(const char *path) { WDPBRec wdpb; Str255 mypath; OSErr error; strcpy(mypath, path); c2pstr(mypath); wdpb.ioNamePtr = mypath; wdpb.ioVRefNum = 0; wdpb.ioWDDirID = 0; error = PBHSetVolSync(&wdpb); return error == noErr ? 0 : -1; }
int __cdecl _chdrive ( int drive ) { OSErr osErr; WDPBRec wdPB; wdPB.ioNamePtr = NULL; wdPB.ioWDDirID = 0; wdPB.ioVRefNum = drive; osErr = PBHSetVolSync(&wdPB); if (osErr) { return -1; } return 0; }
int __cdecl _chdir ( const char *path ) { WDPBRec wdPB; char st[256]; OSErr osErr; ParamBlockRec parm; if (!*path) { errno = ENOENT; return -1; } strcpy(st, path); wdPB.ioNamePtr = _c2pstr(st); wdPB.ioVRefNum = 0; wdPB.ioWDDirID = 0; osErr = PBHSetVolSync(&wdPB); if (osErr) { /* error occured -- map error code and return */ _dosmaperr(osErr); return -1; } osErr = PBHGetVolSync(&wdPB); if (osErr) { /* error occured -- map error code and return */ _dosmaperr(osErr); return -1; } CurDirStore = wdPB.ioWDDirID; SFSaveDisk = wdPB.ioWDVRefNum; memset(&parm, 0, sizeof(ParamBlockRec)); osErr = PBSetVolSync(&parm); return 0; }