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

Function write_dlb_directory

util/dlb_main.c:500–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498}
499
500static void
501write_dlb_directory(int out, int nfiles, libdir *ld,
502 long slen, long dir_size, long flen)
503{
504 char buf[BUFSIZ];
505 int i;
506
507 sprintf(buf, "%3ld %8ld %8ld %8ld %8ld\n",
508 (long) DLB_VERS, /* version of dlb file */
509 (long) nfiles + 1, /* # of entries (includes directory) */
510 /* string length + room for nulls */
511 (long) slen + (long) strlen(DLB_DIRECTORY) + nfiles + 1,
512 (long) dir_size, /* start of first file */
513 (long) flen + dir_size); /* total file size */
514 Write(out, buf, strlen(buf));
515
516/* write each file entry */
517#define ENTRY_FORMAT "%c%s %8ld\n"
518 sprintf(buf, ENTRY_FORMAT, ENC_NORMAL, DLB_DIRECTORY, (long) 0);
519 Write(out, buf, strlen(buf));
520 for (i = 0; i < nfiles; i++) {
521 sprintf(buf, ENTRY_FORMAT, ENC_NORMAL, /* encoding */
522 ld[i].fname, /* name */
523 ld[i].foffset + dir_size); /* offset */
524 Write(out, buf, strlen(buf));
525 }
526}
527
528#endif /* DLBLIB */
529#endif /* DLB */

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected