Don't chdir with NOCWD_ASSUMPTIONS

This commit is contained in:
nethack.allison
2002-08-21 03:26:25 +00:00
parent a25766c471
commit 591b832a84
3 changed files with 21 additions and 3 deletions

View File

@@ -221,7 +221,7 @@ char *argv[];
*/
if (!strncmp(argv[1], "-s", 2)) {
#if !defined(MSWIN_GRAPHICS)
# ifdef CHDIR
# if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdirx(hackdir,0);
# endif
prscore(argc, argv);
@@ -252,7 +252,7 @@ char *argv[];
/* chdir shouldn't be called before this point to keep the
* code parallel to other ports.
*/
#ifdef CHDIR
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdirx(hackdir,1);
#endif

View File

@@ -95,7 +95,9 @@ dosh()
# endif
suspend_nhwindows((char *)0);
# endif /* TOS */
# ifndef NOCWD_ASSUMPTIONS
chdirx(orgdir, 0);
# endif
# ifdef __GO32__
if (system(comspec) < 0) { /* wsu@eecs.umich.edu */
# else
@@ -120,7 +122,9 @@ dosh()
if (iflags.BIOS)
(void)Cursconf(1, -1);
# endif
# ifndef NOCWD_ASSUMPTIONS
chdirx(hackdir, 0);
# endif
get_scr_size(); /* maybe the screen mode changed (TH) */
# if defined(MSDOS) && defined(NO_TERMS)
if (grmode) gr_init();
@@ -512,7 +516,7 @@ static void msexit()
#ifdef MFLOPPY
if (ramdisk) copybones(TOPERM);
#endif
#ifdef CHDIR
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdir(orgdir); /* chdir, not chdirx */
chdrive(orgdir);
#endif

View File

@@ -106,7 +106,9 @@ getlock()
/* we ignore QUIT and INT at this point */
if (!lock_file(HLOCK, LOCKPREFIX, 10)) {
wait_synch();
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdirx(orgdir, 0);
#endif
error("Quitting.");
}
@@ -116,7 +118,9 @@ getlock()
fq_lock = fqname(lock, LEVELPREFIX, 1);
if((fd = open(fq_lock,0)) == -1) {
if(errno == ENOENT) goto gotlock; /* no such file */
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdirx(orgdir, 0);
#endif
#if defined(WIN32)
error("Bad directory or name: %s\n%s\n",
fq_lock, strerror(errno));
@@ -169,12 +173,16 @@ getlock()
goto gotlock;
} else {
unlock_file(HLOCK);
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdirx(orgdir, 0);
#endif
error("Couldn't destroy old game.");
}
else {
unlock_file(HLOCK);
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdirx(orgdir, 0);
#endif
error("%s", "");
}
@@ -183,7 +191,9 @@ gotlock:
if (fd == -1) ern = errno;
unlock_file(HLOCK);
if(fd == -1) {
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdirx(orgdir, 0);
#endif
#if defined(WIN32)
error("cannot creat file (%s.)\n%s\n%s\"%s\" exists?\n",
fq_lock, strerror(ern), " Are you sure that the directory",
@@ -194,11 +204,15 @@ gotlock:
} else {
if(write(fd, (char *) &hackpid, sizeof(hackpid))
!= sizeof(hackpid)){
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdirx(orgdir, 0);
#endif
error("cannot write lock (%s)", fq_lock);
}
if(close(fd) == -1) {
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
chdirx(orgdir, 0);
#endif
error("cannot close lock (%s)", fq_lock);
}
}