]> granicus.if.org Git - nethack/commitdiff
Don't chdir with NOCWD_ASSUMPTIONS
authornethack.allison <nethack.allison>
Wed, 21 Aug 2002 03:26:25 +0000 (03:26 +0000)
committernethack.allison <nethack.allison>
Wed, 21 Aug 2002 03:26:25 +0000 (03:26 +0000)
sys/share/pcmain.c
sys/share/pcsys.c
sys/share/pcunix.c

index 2da4d4280063fc6006687d96e1e4a1ea735a24f2..41d8ed31c2315c01e57e10168a0bbf143642c8ad 100644 (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
 
index 38a4c072433f7b890a97738186eda8aa9ea10770..9c3f762845b5e2861e41c4c9b95c3d3cc2e3f24a 100644 (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
index 7f63f4e3a4c9c1fae9fdd4254fa9f5867d32c39a..96d7c58653927e4bafaf942645101280b765b636 100644 (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);
                }
        }