MCPcopy Create free account
hub / github.com/Gregwar/fatcat / getEntries

Method getEntries

src/core/FatSystem.cpp:328–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326}
327
328vector<FatEntry> FatSystem::getEntries(unsigned int cluster, int *clusters, bool *hasFree)
329{
330 bool isRoot = false;
331 bool contiguous = false;
332 int foundEntries = 0;
333 int badEntries = 0;
334 bool isValid = false;
335 set<unsigned int> visited;
336 vector<FatEntry> entries;
337 FatFilename filename;
338
339 if (clusters != NULL) {
340 *clusters = 0;
341 }
342
343 if (hasFree != NULL) {
344 *hasFree = false;
345 }
346
347 if (cluster == 0 && type == FAT32) {
348 cluster = rootDirectory;
349 }
350
351 isRoot = (type==FAT16 && cluster==rootDirectory);
352
353 if (cluster == rootDirectory) {
354 isValid = true;
355 }
356
357 if (!validCluster(cluster)) {
358 return vector<FatEntry>();
359 }
360
361 do {
362 bool localZero = false;
363 int localFound = 0;
364 int localBadEntries = 0;
365 unsigned long long address = clusterAddress(cluster, isRoot);
366 char buffer[FAT_ENTRY_SIZE];
367 if (visited.find(cluster) != visited.end()) {
368 cerr << "! Looping directory" << endl;
369 break;
370 }
371 visited.insert(cluster);
372
373 unsigned int i;
374 for (i=0; i<bytesPerCluster; i+=sizeof(buffer)) {
375 // Reading data
376 readData(address, buffer, sizeof(buffer));
377
378 // Creating entry
379 FatEntry entry;
380
381 entry.attributes = buffer[FAT_ATTRIBUTES];
382 entry.address = address;
383
384 if (entry.attributes == FAT_ATTRIBUTES_LONGFILE) {
385 // Long file part

Callers 4

doWalkMethod · 0.80
onEntryMethod · 0.80
exploreChainsMethod · 0.80
recursiveExplorationMethod · 0.80

Calls 6

FatDateClass · 0.85
appendMethod · 0.80
setDataMethod · 0.80
isZeroMethod · 0.80
isCorrectMethod · 0.80
getFilenameMethod · 0.45

Tested by

no test coverage detected