MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getEntries

Method getEntries

valdi_core/src/valdi_core/cpp/Resources/ValdiArchive.cpp:63–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63Result<std::vector<ValdiArchiveEntry>> ValdiArchive::getEntries() const {
64 auto dataSection = ValdiPacket::read(_dataBegin, _dataEnd - _dataBegin);
65 if (!dataSection) {
66 return onModuleFailure(dataSection.moveError());
67 }
68
69 std::vector<ValdiArchiveEntry> entries;
70 auto parser = Parser(dataSection.value().begin(), dataSection.value().end());
71 while (!parser.isAtEnd()) {
72 auto& entry = entries.emplace_back(StringBox(), nullptr, 0);
73 auto filenameLength = parser.parseValue<LengthField>();
74 if (!filenameLength) {
75 return onModuleFailure(filenameLength.moveError());
76 }
77
78 auto filename = parseField(parser, filenameLength.value());
79 if (!filename) {
80 return onModuleFailure(filename.moveError());
81 }
82
83 auto dataLength = parser.parseValue<LengthField>();
84 if (!dataLength) {
85 return onModuleFailure(dataLength.moveError());
86 }
87
88 auto data = parseField(parser, dataLength.value());
89 if (!data) {
90 return onModuleFailure(data.moveError());
91 }
92
93 auto path = StringCache::getGlobal().makeString(reinterpret_cast<const char*>(filename.value().data()),
94 filename.value().size());
95
96 entry.data = data.value().data();
97 entry.dataLength = dataLength.value().size();
98 entry.filePath = std::move(path);
99 }
100
101 return entries;
102}
103
104ValdiArchiveEntry::ValdiArchiveEntry(StringBox filePath, const Byte* data, size_t dataLength)
105 : filePath(std::move(filePath)), data(data), dataLength(dataLength) {}

Callers

nothing calls this directly

Calls 12

onModuleFailureFunction · 0.85
parseFieldFunction · 0.85
getGlobalFunction · 0.85
makeStringMethod · 0.80
valueMethod · 0.65
endMethod · 0.65
ParserClass · 0.50
StringBoxClass · 0.50
beginMethod · 0.45
isAtEndMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected