| 342 | |
| 343 | #ifdef CHDIR |
| 344 | void |
| 345 | chdirx(const char *dir, boolean wr) |
| 346 | { |
| 347 | #ifndef HACKDIR |
| 348 | static const char *defdir = "."; |
| 349 | #else |
| 350 | static const char *defdir = HACKDIR; |
| 351 | |
| 352 | if (dir == (const char *) 0) |
| 353 | dir = defdir; |
| 354 | else if (wr && !same_dir(HACKDIR, dir)) |
| 355 | /* If we're playing anywhere other than HACKDIR, turn off any |
| 356 | privs we may have been installed with. */ |
| 357 | privoff(); |
| 358 | #endif |
| 359 | |
| 360 | if (dir && chdir(dir) < 0) { |
| 361 | perror(dir); |
| 362 | error("Cannot chdir to %s.", dir); |
| 363 | } |
| 364 | |
| 365 | /* warn the player if we can't write the record file */ |
| 366 | if (wr) |
| 367 | check_recordfile(dir); |
| 368 | |
| 369 | defdir = dir; |
| 370 | } |
| 371 | #endif /* CHDIR */ |
| 372 | |
| 373 | static void |
no test coverage detected