MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / getFile

Method getFile

lib/vfs/prodos.cc:192–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190 }
191
192 Bytes getFile(const Path& path) override
193 {
194 mount();
195
196 auto dir = chdir(path.parent());
197 auto dirent = dir->find(path.back());
198
199 Bytes bytes;
200 switch (dirent->storageType)
201 {
202 case STORAGETYPE_SUBDIR:
203 throw BadPathException("tried to use a directory like a file");
204
205 case STORAGETYPE_SEEDLING:
206 bytes = getLogicalBlock(dirent->keyBlock);
207 break;
208
209 case STORAGETYPE_SAPLING:
210 {
211 auto keyBytes = getLogicalBlock(dirent->keyBlock);
212 ByteWriter bw(bytes);
213 readIndexBlock(keyBytes, bw);
214 break;
215 }
216
217 case STORAGETYPE_TREE:
218 {
219 auto masterKeyBytes = getLogicalBlock(dirent->keyBlock);
220 ByteWriter bw(bytes);
221 ByteReader br(masterKeyBytes);
222
223 /* This always appends 16MB of data, the maximum amount
224 * for a tree file, which is wasteful but simple.
225 */
226
227 while (!br.eof())
228 {
229 uint16_t indexBlock = br.read_le16();
230 if (indexBlock)
231 readIndexBlock(getLogicalBlock(indexBlock), bw);
232 else
233 bw += Bytes(128 * 1024);
234 }
235 break;
236 }
237
238 default:
239 throw UnimplementedFilesystemException(
240 fmt::format("storage type 0x{:x} isn't supported yet",
241 dirent->storageType));
242 }
243
244 return bytes.slice(0, dirent->length);
245 }
246
247private:
248 void mount()

Callers

nothing calls this directly

Calls 8

BadPathExceptionClass · 0.85
parentMethod · 0.80
read_le16Method · 0.80
sliceMethod · 0.80
BytesClass · 0.50
findMethod · 0.45
eofMethod · 0.45

Tested by

no test coverage detected