fix an issue with internal recover (Windows)
This commit is contained in:
+19
-10
@@ -660,8 +660,9 @@ create_levelfile(int lev, char errbuf[])
|
|||||||
Sprintf(errbuf,
|
Sprintf(errbuf,
|
||||||
"Cannot create file \"%s\" for level %d (errno %d).",
|
"Cannot create file \"%s\" for level %d (errno %d).",
|
||||||
gl.lock, lev, errno);
|
gl.lock, lev, errno);
|
||||||
#if defined(MSDOS)
|
#if defined(MSDOS) || defined(WIN32)
|
||||||
setmode(nhfp->fd, O_BINARY);
|
if (nhfp->fd >= 0)
|
||||||
|
(void) setmode(nhfp->fd, O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
nhfp = viable_nhfile(nhfp);
|
nhfp = viable_nhfile(nhfp);
|
||||||
@@ -705,8 +706,9 @@ open_levelfile(int lev, char errbuf[])
|
|||||||
Sprintf(errbuf,
|
Sprintf(errbuf,
|
||||||
"Cannot open file \"%s\" for level %d (errno %d).",
|
"Cannot open file \"%s\" for level %d (errno %d).",
|
||||||
gl.lock, lev, errno);
|
gl.lock, lev, errno);
|
||||||
#if defined(MSDOS)
|
#if defined(MSDOS) || defined(WIN32)
|
||||||
setmode(nhfp->fd, O_BINARY);
|
if (nhfp->fd >= 0)
|
||||||
|
(void) setmode(nhfp->fd, O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
nhfp = viable_nhfile(nhfp);
|
nhfp = viable_nhfile(nhfp);
|
||||||
@@ -883,8 +885,9 @@ create_bonesfile(d_level *lev, char **bonesid, char errbuf[])
|
|||||||
#endif /* ?MICRO || WIN32 */
|
#endif /* ?MICRO || WIN32 */
|
||||||
if (nhfp->fd < 0)
|
if (nhfp->fd < 0)
|
||||||
failed = errno;
|
failed = errno;
|
||||||
#if defined(MSDOS)
|
#if defined(MSDOS) || defined(WIN32)
|
||||||
setmode(nhfp->fd, O_BINARY);
|
if (nhfp->fd >= 0)
|
||||||
|
(void) setmode(nhfp->fd, O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (failed && errbuf) /* failure explanation */
|
if (failed && errbuf) /* failure explanation */
|
||||||
@@ -976,8 +979,9 @@ open_bonesfile(d_level *lev, char **bonesid)
|
|||||||
#else
|
#else
|
||||||
nhfp->fd = open(fq_bones, O_RDONLY | O_BINARY, 0);
|
nhfp->fd = open(fq_bones, O_RDONLY | O_BINARY, 0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(MSDOS)
|
#if defined(MSDOS) || defined(WIN32)
|
||||||
setmode(nhfp->fd, O_BINARY);
|
if (nhfp->fd >= 0)
|
||||||
|
(void) setmode(nhfp->fd, O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1188,8 +1192,8 @@ create_savefile(void)
|
|||||||
#endif
|
#endif
|
||||||
#endif /* MICRO || WIN32 */
|
#endif /* MICRO || WIN32 */
|
||||||
#if defined(MSDOS) || defined(WIN32)
|
#if defined(MSDOS) || defined(WIN32)
|
||||||
if (nhfp->fd >= 0)
|
if (nhfp->fd >= 0)
|
||||||
(void) setmode(nhfp->fd, O_BINARY);
|
(void) setmode(nhfp->fd, O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2989,6 +2993,9 @@ recover_savefile(void)
|
|||||||
if (savewrite_failure)
|
if (savewrite_failure)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (snhfp->structlevel)
|
||||||
|
bufoff(snhfp->fd);
|
||||||
|
|
||||||
/* TODO: this is not a single byte, so a big-endian byte swap
|
/* TODO: this is not a single byte, so a big-endian byte swap
|
||||||
* might be necessary here, if anyone is concerned about big-endian */
|
* might be necessary here, if anyone is concerned about big-endian */
|
||||||
Sfo_int(snhfp, &pltmpsiz, "plname-size");
|
Sfo_int(snhfp, &pltmpsiz, "plname-size");
|
||||||
@@ -3041,6 +3048,8 @@ recover_savefile(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (snhfp->structlevel)
|
||||||
|
bufon(snhfp->fd);
|
||||||
close_nhfile(snhfp);
|
close_nhfile(snhfp);
|
||||||
/*
|
/*
|
||||||
* We have a successful savefile!
|
* We have a successful savefile!
|
||||||
|
|||||||
Reference in New Issue
Block a user