@@ -51,7 +51,7 @@ void FatSystem::enableCache()
5151 for (int cluster=0 ; cluster<totalClusters; cluster++) {
5252 cache[cluster] = nextCluster (cluster);
5353 }
54-
54+
5555 cacheEnabled = true ;
5656 }
5757}
@@ -67,7 +67,7 @@ void FatSystem::enableWrite()
6767
6868 throw oss.str ();
6969 }
70-
70+
7171 writeMode = true ;
7272}
7373
@@ -136,7 +136,7 @@ void FatSystem::parseHeader()
136136 reservedSectors = FAT_READ_SHORT (buffer, FAT_RESERVED_SECTORS )&0xffff ;
137137 oemName = string (buffer+FAT_DISK_OEM , FAT_DISK_OEM_SIZE );
138138 fats = buffer[FAT_FATS ];
139-
139+
140140 sectorsPerFat = FAT_READ_SHORT (buffer, FAT16_SECTORS_PER_FAT )&0xffff ;
141141
142142 if (sectorsPerFat != 0 ) {
@@ -193,7 +193,7 @@ unsigned int FatSystem::nextCluster(unsigned int cluster, int fat)
193193{
194194 int bytes = (bits == 32 ? 4 : 2 );
195195 char buffer[bytes];
196-
196+
197197 if (!validCluster (cluster)) {
198198 return 0 ;
199199 }
@@ -205,7 +205,7 @@ unsigned int FatSystem::nextCluster(unsigned int cluster, int fat)
205205 readData (fatStart+fatSize*fat+(bits*cluster)/8 , buffer, sizeof (buffer));
206206
207207 unsigned int next;
208-
208+
209209 if (type == FAT32 ) {
210210 next = FAT_READ_LONG (buffer, 0 )&0x0fffffff ;
211211
@@ -237,7 +237,7 @@ unsigned int FatSystem::nextCluster(unsigned int cluster, int fat)
237237 }
238238 }
239239}
240-
240+
241241/* *
242242 * Changes the next cluster in a file
243243 */
@@ -251,7 +251,7 @@ bool FatSystem::writeNextCluster(unsigned int cluster, unsigned int next, int fa
251251 }
252252
253253 int offset = fatStart+fatSize*fat+(bits*cluster)/8 ;
254-
254+
255255 if (bits == 12 ) {
256256 readData (offset, buffer, bytes);
257257 int bit = cluster*bits;
@@ -271,7 +271,7 @@ bool FatSystem::writeNextCluster(unsigned int cluster, unsigned int next, int fa
271271
272272 return writeData (offset, buffer, bytes) == bytes;
273273}
274-
274+
275275bool FatSystem::validCluster (unsigned int cluster)
276276{
277277 return cluster < totalClusters;
@@ -283,7 +283,7 @@ unsigned long long FatSystem::clusterAddress(unsigned int cluster, bool isRoot)
283283 cluster -= 2 ;
284284 }
285285
286- int addr = (dataStart + bytesPerSector*sectorsPerCluster*cluster);
286+ unsigned long long addr = (dataStart + bytesPerSector*sectorsPerCluster*cluster);
287287
288288 if (type == FAT16 && !isRoot) {
289289 addr += rootEntries * FAT_ENTRY_SIZE ;
@@ -394,7 +394,7 @@ vector<FatEntry> FatSystem::getEntries(unsigned int cluster, int *clusters, bool
394394 } else {
395395 cluster = nextCluster (cluster);
396396 }
397-
397+
398398 if (clusters) {
399399 (*clusters)++;
400400 }
@@ -422,10 +422,10 @@ vector<FatEntry> FatSystem::getEntries(unsigned int cluster, int *clusters, bool
422422 }
423423 }
424424 } while (cluster != FAT_LAST );
425-
425+
426426 return entries;
427427}
428-
428+
429429void FatSystem::list (FatPath &path)
430430{
431431 FatEntry entry;
@@ -445,7 +445,7 @@ void FatSystem::list(unsigned int cluster)
445445 }
446446 list (entries);
447447}
448-
448+
449449void FatSystem::list (vector<FatEntry> &entries)
450450{
451451 vector<FatEntry>::iterator it;
@@ -472,7 +472,7 @@ void FatSystem::list(vector<FatEntry> &entries)
472472 printf (" %-30s" , name.c_str ());
473473
474474 printf (" c=%u" , entry.cluster );
475-
475+
476476 if (!entry.isDirectory ()) {
477477 string pretty = prettySize (entry.size );
478478 printf (" s=%llu (%s)" , entry.size , pretty.c_str ());
@@ -564,7 +564,7 @@ bool FatSystem::init()
564564
565565 return strange == 0 ;
566566}
567-
567+
568568void FatSystem::infos ()
569569{
570570 cout << " FAT Filesystem information" << endl << endl;
@@ -595,13 +595,13 @@ void FatSystem::infos()
595595 computeStats ();
596596 cout << " Free clusters: " << freeClusters << " /" << totalClusters;
597597 cout << " (" << (100 *freeClusters/(double )totalClusters) << " %)" << endl;
598- cout << " Free space: " << (freeClusters*bytesPerCluster) <<
598+ cout << " Free space: " << (freeClusters*bytesPerCluster) <<
599599 " (" << prettySize (freeClusters*bytesPerCluster) << " )" << endl;
600- cout << " Used space: " << ((totalClusters-freeClusters)*bytesPerCluster) <<
600+ cout << " Used space: " << ((totalClusters-freeClusters)*bytesPerCluster) <<
601601 " (" << prettySize ((totalClusters-freeClusters)*bytesPerCluster) << " )" << endl;
602602 cout << endl;
603603}
604-
604+
605605bool FatSystem::findDirectory (FatPath &path, FatEntry &outputEntry)
606606{
607607 int cluster;
@@ -665,11 +665,11 @@ bool FatSystem::findFile(FatPath &path, FatEntry &outputEntry)
665665
666666 return found;
667667}
668-
668+
669669void FatSystem::readFile (FatPath &path, FILE *f)
670670{
671671 FatEntry entry;
672-
672+
673673 if (findFile (path, entry)) {
674674 bool contiguous = false ;
675675 if (entry.isErased () && freeCluster (entry.cluster )) {
@@ -679,12 +679,12 @@ void FatSystem::readFile(FatPath &path, FILE *f)
679679 readFile (entry.cluster , entry.size , f, contiguous);
680680 }
681681}
682-
682+
683683void FatSystem::setListDeleted (bool listDeleted_)
684684{
685685 listDeleted = listDeleted_;
686686}
687-
687+
688688FatEntry FatSystem::rootEntry ()
689689{
690690 FatEntry entry;
@@ -699,7 +699,7 @@ bool FatSystem::freeCluster(unsigned int cluster)
699699{
700700 return nextCluster (cluster) == 0 ;
701701}
702-
702+
703703void FatSystem::computeStats ()
704704{
705705 if (statsComputed) {
0 commit comments