mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +02:00
wip
This commit is contained in:
parent
4764305fd7
commit
52585c99a1
@ -365,12 +365,12 @@ int verifyChecksumFromFlash(char *mess, char *clientChecksum, char *fname,
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
const int readUnitSize = 128;
|
const int readUnitSize = 128;
|
||||||
char buf[readUnitSize];
|
char buf[readUnitSize]{};
|
||||||
ssize_t bytes = fread(buf, 1, readUnitSize, fp);
|
int c = fgetc(fp);
|
||||||
ssize_t totalBytesRead = bytes;
|
|
||||||
int oldProgress = 0;
|
int oldProgress = 0;
|
||||||
|
ssize_t totalBytesRead = 1;
|
||||||
|
|
||||||
while (bytes > 0) {
|
while (!feof(fp)) {
|
||||||
int progress = (int)(((double)(totalBytesRead) / fsize) * 100);
|
int progress = (int)(((double)(totalBytesRead) / fsize) * 100);
|
||||||
if (oldProgress != progress) {
|
if (oldProgress != progress) {
|
||||||
printf("%d%%\r", progress);
|
printf("%d%%\r", progress);
|
||||||
@ -384,7 +384,7 @@ int verifyChecksumFromFlash(char *mess, char *clientChecksum, char *fname,
|
|||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
if (fwrite((void *)buf, sizeof(char), bytes, flashfp) != bytes) {
|
if (fputc(c, flashfp) != c) {
|
||||||
LOG(logERROR, ("Could not write to flash fp file\n"));
|
LOG(logERROR, ("Could not write to flash fp file\n"));
|
||||||
}
|
}
|
||||||
// read only until a particular size (drive)
|
// read only until a particular size (drive)
|
||||||
@ -392,8 +392,8 @@ int verifyChecksumFromFlash(char *mess, char *clientChecksum, char *fname,
|
|||||||
LOG(logINFOBLUE, ("\tReached %lu bytes. Not reading more\n", totalBytesRead));
|
LOG(logINFOBLUE, ("\tReached %lu bytes. Not reading more\n", totalBytesRead));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bytes = fread(buf, 1, readUnitSize, fp);
|
c = fgetc(fp);
|
||||||
totalBytesRead += bytes;
|
++totalBytesRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO, ("\tRead %lu bytes to calculate checksum\n", totalBytesRead));
|
LOG(logINFO, ("\tRead %lu bytes to calculate checksum\n", totalBytesRead));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user