| 328 | //========================================================================== |
| 329 | |
| 330 | void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInfo* filter, FileSystemMessageFunc Printf) |
| 331 | { |
| 332 | int startlump; |
| 333 | bool isdir = false; |
| 334 | FileReader filereader; |
| 335 | |
| 336 | if (filer == nullptr) |
| 337 | { |
| 338 | // Does this exist? If so, is it a directory? |
| 339 | if (!FS_DirEntryExists(filename, &isdir)) |
| 340 | { |
| 341 | if (Printf) |
| 342 | { |
| 343 | Printf(FSMessageLevel::Error, "%s: File or Directory not found\n", filename); |
| 344 | PrintLastError(Printf); |
| 345 | } |
| 346 | return; |
| 347 | } |
| 348 | |
| 349 | if (!isdir) |
| 350 | { |
| 351 | if (!filereader.OpenFile(filename)) |
| 352 | { // Didn't find file |
| 353 | if (Printf) |
| 354 | { |
| 355 | Printf(FSMessageLevel::Error, "%s: File not found\n", filename); |
| 356 | PrintLastError(Printf); |
| 357 | } |
| 358 | return; |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | else filereader = std::move(*filer); |
| 363 | |
| 364 | startlump = NumEntries; |
| 365 | |
| 366 | FResourceFile *resfile; |
| 367 | |
| 368 | |
| 369 | if (!isdir) |
| 370 | resfile = FResourceFile::OpenResourceFile(filename, filereader, false, filter, Printf, stringpool); |
| 371 | else |
| 372 | resfile = FResourceFile::OpenDirectory(filename, filter, Printf, stringpool); |
| 373 | |
| 374 | if (resfile != NULL) |
| 375 | { |
| 376 | if (Printf) |
| 377 | Printf(FSMessageLevel::Message, "adding %s, %d lumps\n", filename, resfile->EntryCount()); |
| 378 | |
| 379 | uint32_t lumpstart = (uint32_t)FileInfo.size(); |
| 380 | |
| 381 | resfile->SetFirstLump(lumpstart); |
| 382 | Files.push_back(resfile); |
| 383 | for (int i = 0; i < resfile->EntryCount(); i++) |
| 384 | { |
| 385 | FileInfo.resize(FileInfo.size() + 1); |
| 386 | FileSystem::LumpRecord* lump_p = &FileInfo.back(); |
| 387 | lump_p->SetFromLump(resfile, i, (int)Files.size() - 1, stringpool); |
nothing calls this directly
no test coverage detected