// // WriteDirectory // // Returns number of entries written. // static int WriteDirectory(void) { lump_t *cur, *L; int count = 0; if (ftell(out_file) != wad.dir_start) PrintWarn("Consistency failure writing lump directory " "(%08lX,%08X)\n", ftell(out_file), wad.dir_start); for (cur=wad.dir_head; cur; cur=cur->next) { if (cur->flags & LUMP_IGNORE_ME) continue; WriteDirEntry(cur); count++; # if DEBUG_DIR if (cur->lev_info) PrintDebug("Write dir... %s :\n", cur->name); else PrintDebug("Write dir... %s\n", cur->name); # endif if (cur->lev_info) { for (L=cur->lev_info->children; L; L=L->next) { if (cur->flags & LUMP_IGNORE_ME) continue; # if DEBUG_DIR PrintDebug("Write dir... |--- %s\n", L->name); # endif WriteDirEntry(L); count++; } } } fflush(out_file); return count; }
static BOOL CleanRootDir(RDWRHandle handle) { unsigned short NumberOfRootEntries, i; struct DirectoryEntry entry; memset(&entry, 0, sizeof(struct DirectoryEntry)); NumberOfRootEntries = GetNumberOfRootEntries(handle); if (!NumberOfRootEntries) return FALSE; for (i = NumberOfRootEntries-1;; i--) { if (!WriteDirEntry(handle, i, &entry)) return FALSE; if (i == 0) break; } return TRUE; }
static BOOL AddToRootDir(RDWRHandle handle, CLUSTER cluster, unsigned long filesize) { struct DirectoryEntry entry; static unsigned short index = 0; unsigned short NumberOfRootEntries = GetNumberOfRootEntries(handle); if (index < NumberOfRootEntries) { FillNewEntry(&entry, cluster, filesize, index); if (!WriteDirEntry(handle, index, &entry)) return FALSE; index++; return TRUE; } else { printf("Root directory full (or media error)!"); return FALSE; } }