worked on FAT32 stuff
This commit is contained in:
@@ -29,11 +29,11 @@ public:
|
||||
ClusterNr getFirstCluster() const {return dea.getFirstCluster();}
|
||||
|
||||
/** get the file's name */
|
||||
const std::string& getName() const {return dea.getName();}
|
||||
std::string getName() const {return dea.getName();}
|
||||
|
||||
|
||||
/** read x bytes from the file */
|
||||
uint32_t read(uint32_t size, uint8_t* dst, std::function<void(int)> callback) {
|
||||
uint32_t read(uint32_t size, uint8_t* dst) {
|
||||
|
||||
Log::addInfo(NAME, "read %d bytes", size);
|
||||
|
||||
@@ -48,14 +48,14 @@ public:
|
||||
remaining -= read;
|
||||
dst += read;
|
||||
totalRead += read;
|
||||
callback(totalRead*100/size);
|
||||
}
|
||||
|
||||
return totalRead;
|
||||
|
||||
}
|
||||
|
||||
uint32_t write(uint32_t size, const uint8_t* src, std::function<void(int)> callback) {
|
||||
/* write the given data into the file */
|
||||
uint32_t write(uint32_t size, const uint8_t* src) {
|
||||
|
||||
Log::addInfo(NAME, "write %d bytes", size);
|
||||
|
||||
@@ -67,10 +67,10 @@ public:
|
||||
remaining -= written;
|
||||
src += written;
|
||||
totalWritten += written;
|
||||
callback(totalWritten*100/size);
|
||||
//callback(totalWritten*100/size);
|
||||
}
|
||||
|
||||
// update the file header (size might have changed)
|
||||
// update the file header (filesize might have changed)
|
||||
fs.write(dea);
|
||||
|
||||
return totalWritten;
|
||||
@@ -98,10 +98,10 @@ private:
|
||||
}
|
||||
|
||||
// debug
|
||||
char buf[1024];
|
||||
char* dst = buf; dst += sprintf(dst, "clusters: ");
|
||||
for (ClusterNr nr : clusters) {dst += sprintf(dst, "%d ", nr);}
|
||||
Log::addInfo(NAME, buf);
|
||||
//char buf[1024];
|
||||
//char* dst = buf; dst += sprintf(dst, "clusters: ");
|
||||
//for (ClusterNr nr : clusters) {dst += sprintf(dst, "%d ", nr);}
|
||||
//Log::addInfo(NAME, buf);
|
||||
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ private:
|
||||
|
||||
int32_t _write(uint32_t writeSize, const uint8_t* src) {
|
||||
|
||||
// do we need to append more free sectors to the end of the file?
|
||||
if (curAbsPos >= getAllocatedSize()) {
|
||||
if (clusters.empty()) {
|
||||
const ClusterNr newCluster = fs.allocFreeCluster(0);
|
||||
@@ -147,8 +148,6 @@ private:
|
||||
clusters.push_back(newCluster);
|
||||
Log::addInfo(NAME, "allocNextCluster(%d): %d", prevCluster, newCluster);
|
||||
}
|
||||
dea.setSize(dea.getSize() + fs.tmp.bytesPerCluster);
|
||||
fs.write(dea);
|
||||
}
|
||||
|
||||
// end of current cluster reached? -> switch to the next one
|
||||
|
||||
Reference in New Issue
Block a user