MCPcopy Create free account
hub / github.com/ZDoom/Raze / AddFile

Method AddFile

source/common/filesystem/source/filesystem.cpp:330–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328//==========================================================================
329
330void 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);

Callers

nothing calls this directly

Calls 15

FS_DirEntryExistsFunction · 0.85
PrintfFunction · 0.85
PrintLastErrorFunction · 0.85
moveFunction · 0.85
AddFileFunction · 0.85
EntryCountMethod · 0.80
SetFirstLumpMethod · 0.80
SetFromLumpMethod · 0.80
GetEntryFlagsMethod · 0.80
c_strMethod · 0.80
OpenFileMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected