MCPcopy Create free account
hub / github.com/Illation/ETEngine / AddFile

Method AddFile

Engine/source/EtCooker/PackageWriter.cpp:48–70  ·  view source on GitHub ↗

--------------------------------- PackageWriter::AddFile Add a file to the writer and create a package entry for it - takes ownership

Source from the content-addressed store, hash-verified

46// Add a file to the writer and create a package entry for it - takes ownership
47//
48void PackageWriter::AddFile(core::File* const file, std::string const& rootDir, core::E_CompressionType const compression)
49{
50 m_Files.emplace_back(core::PkgEntry(), file, std::string());
51 core::PkgEntry& entry = m_Files[m_Files.size() - 1].entry;
52 std::string& relName = m_Files[m_Files.size() - 1].relName;
53
54 // assign the name the relative path of the file compared to the root directory of the package writer
55 relName = core::FileUtil::GetRelativePath(file->GetName(), rootDir);
56
57 entry.fileId = GetHash(relName);
58 entry.compressionType = compression;
59 entry.nameLength = static_cast<uint16>(relName.size());
60
61 // try opening the file for now, so that we can get the size, keep it open for copying content later
62 if (!file->Open(core::FILE_ACCESS_MODE::Read))
63 {
64 LOG("PackageWriter::AddFile > unable to open file '" + relName + std::string("'!"), core::LogLevel::Warning);
65 return;
66 }
67
68 // get the file size
69 entry.size = file->GetSize();
70}
71
72//---------------------------------
73// PackageWriter::RemoveFile

Callers 2

AddPackageToWriterFunction · 0.80
CookCompiledPackageFunction · 0.80

Calls 4

PkgEntryClass · 0.85
GetNameMethod · 0.80
OpenMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected