equal
deleted
inserted
replaced
35 static bool CalcGRFMD5Sum(GRFConfig *config) |
35 static bool CalcGRFMD5Sum(GRFConfig *config) |
36 { |
36 { |
37 FILE *f; |
37 FILE *f; |
38 md5_state_t md5state; |
38 md5_state_t md5state; |
39 md5_byte_t buffer[1024]; |
39 md5_byte_t buffer[1024]; |
40 size_t len; |
40 size_t len, size; |
41 |
41 |
42 /* open the file */ |
42 /* open the file */ |
43 f = FioFOpenFile(config->filename); |
43 f = FioFOpenFile(config->filename, "rb", DATA_DIR, &size); |
44 if (f == NULL) return false; |
44 if (f == NULL) return false; |
45 |
45 |
46 /* calculate md5sum */ |
46 /* calculate md5sum */ |
47 md5_init(&md5state); |
47 md5_init(&md5state); |
48 while ((len = fread(buffer, 1, sizeof(buffer), f)) != 0) { |
48 while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) { |
|
49 size -= len; |
49 md5_append(&md5state, buffer, len); |
50 md5_append(&md5state, buffer, len); |
50 } |
51 } |
51 md5_finish(&md5state, config->md5sum); |
52 md5_finish(&md5state, config->md5sum); |
52 |
53 |
53 fclose(f); |
54 fclose(f); |