mirror of
https://github.com/glest/glest-source.git
synced 2025-08-21 07:31:21 +02:00
- attempt to speed up file CRC algorithm
This commit is contained in:
@@ -87,6 +87,9 @@ void Checksum::addFileToSum(const string &path){
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
const double MAX_CRC_FILESIZE = 100000000;
|
const double MAX_CRC_FILESIZE = 100000000;
|
||||||
int fd=0;
|
int fd=0;
|
||||||
size_t bytes_read, bytes_expected = MAX_CRC_FILESIZE * sizeof(int8);
|
size_t bytes_read, bytes_expected = MAX_CRC_FILESIZE * sizeof(int8);
|
||||||
@@ -108,6 +111,35 @@ void Checksum::addFileToSum(const string &path){
|
|||||||
addByte(data[i]);
|
addByte(data[i]);
|
||||||
}
|
}
|
||||||
free(data);
|
free(data);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
FILE* file= fopen(path.c_str(), "rb");
|
||||||
|
if(file!=NULL){
|
||||||
|
|
||||||
|
addString(lastFile(path));
|
||||||
|
|
||||||
|
char buf[4096]=""; /* Should be large enough. */
|
||||||
|
int bufSize = sizeof buf;
|
||||||
|
while(!feof(file)){
|
||||||
|
//int8 byte= 0;
|
||||||
|
|
||||||
|
//size_t readBytes = fread(&byte, 1, 1, file);
|
||||||
|
memset(buf,0,bufSize);
|
||||||
|
if(fgets(buf, bufSize, file) != NULL) {
|
||||||
|
//addByte(byte);
|
||||||
|
for(int i = 0; buf[i] != 0 && i < bufSize; i++) {
|
||||||
|
addByte(buf[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw runtime_error("Can not open file: " + path);
|
||||||
|
}
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 Checksum::getSum() {
|
int32 Checksum::getSum() {
|
||||||
|
Reference in New Issue
Block a user