MCPcopy Create free account
hub / github.com/NetHack/NetHack / chdir

Function chdir

sys/amiga/amidos.c:452–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450static BPTR OrgDirLock = NO_LOCK;
451
452int
453chdir(
454#ifdef CROSS_TO_AMIGA
455 const
456#endif
457 char *dir)
458{
459 extern char orgdir[];
460
461 if (dir == orgdir) {
462 /* We want to go back to where we came from. */
463 if (OrgDirLock != NO_LOCK) {
464 UnLock(CurrentDir(OrgDirLock));
465 OrgDirLock = NO_LOCK;
466 }
467 } else {
468 /*
469 * Go to some new place. If still at the original
470 * directory, save the FileLock.
471 */
472 BPTR newDir;
473
474 if (newDir = Lock((char *) dir, SHARED_LOCK)) {
475 if (OrgDirLock == NO_LOCK) {
476 OrgDirLock = CurrentDir(newDir);
477 } else {
478 UnLock(CurrentDir(newDir));
479 }
480 } else {
481 return -1; /* Failed */
482 }
483 }
484 /* CurrentDir always succeeds if you have a lock */
485 return 0;
486}
487
488#endif /* CHDIR */
489

Callers 15

nethack_exitFunction · 0.70
AbortFunction · 0.70
mainFunction · 0.50
chdirxFunction · 0.50
childFunction · 0.50
chdirxFunction · 0.50
MAINFunction · 0.50
chdirxFunction · 0.50
chdirxFunction · 0.50
byebyeFunction · 0.50
vms_doshellFunction · 0.50
msexitFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected