MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / collectFiles

Function collectFiles

switch/source/transfer.cpp:110–150  ·  view source on GitHub ↗

Returns false if any regular file exceeds the store-zip entry limit; such a file cannot be framed (no zip64) and the whole send must refuse rather than truncate the size to u32.

Source from the content-addressed store, hash-verified

108 // file cannot be framed (no zip64) and the whole send must refuse rather than
109 // truncate the size to u32.
110 bool collectFiles(const std::string& root, const std::string& sub, std::vector<SendFile>& out, std::vector<std::string>* outDirs = nullptr)
111 {
112 std::string current = root;
113 if (!current.empty() && current.back() != '/') {
114 current += "/";
115 }
116 current += sub;
117 Directory items(current);
118 if (!items.good()) {
119 return true;
120 }
121 bool ok = true;
122 for (size_t i = 0, sz = items.size(); i < sz; i++) {
123 std::string name = items.entry(i);
124 if (name == "." || name == "..") {
125 continue;
126 }
127 if (items.folder(i)) {
128 std::string nextSub = sub + name + "/";
129 if (outDirs != nullptr) {
130 outDirs->push_back(nextSub);
131 }
132 if (!collectFiles(root, nextSub, out, outDirs)) {
133 ok = false;
134 }
135 }
136 else {
137 SendFile entry;
138 entry.absPath = current + name;
139 entry.relPath = sub + name;
140 u64 sz64 = fileSize(entry.absPath);
141 if (sz64 > TransferProto::kZipMaxSize) {
142 ok = false;
143 continue;
144 }
145 entry.size = (u32)sz64;
146 out.push_back(entry);
147 }
148 }
149 return ok;
150 }
151
152 void ensureDirectoryPath(const std::string& base, const std::string& relPath)
153 {

Callers 1

sendBackupMethod · 0.70

Calls 8

fileSizeFunction · 0.85
backMethod · 0.80
emptyMethod · 0.45
goodMethod · 0.45
sizeMethod · 0.45
entryMethod · 0.45
folderMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected