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

Function eraseoldlocks

sys/windows/windmain.c:990–1011  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

988
989#ifdef PC_LOCKING
990static int
991eraseoldlocks(void)
992{
993 int i;
994
995 /* cannot use maxledgerno() here, because we need to find a lock name
996 * before starting everything (including the dungeon initialization
997 * that sets astral_level, needed for maxledgerno()) up
998 */
999 for (i = 1; i <= MAXDUNGEON * MAXLEVEL + 1; i++) {
1000 /* try to remove all */
1001 set_levelfile_name(gl.lock, i);
1002 (void) unlink(fqname(gl.lock, LEVELPREFIX, 0));
1003 }
1004 set_levelfile_name(gl.lock, 0);
1005#ifdef HOLD_LOCKFILE_OPEN
1006 really_close();
1007#endif
1008 if (unlink(fqname(gl.lock, LEVELPREFIX, 0)))
1009 return 0; /* cannot remove it */
1010 return (1); /* success! */
1011}
1012
1013DISABLE_WARNING_UNREACHABLE_CODE
1014

Callers 1

getlockFunction · 0.70

Calls 3

unlinkFunction · 0.85
fqnameFunction · 0.85
set_levelfile_nameFunction · 0.50

Tested by

no test coverage detected