fixed bug with big files. To be tested.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4055 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2011-02-24 22:19:04 +00:00
parent 161066a5d9
commit f6dc46da73

View File

@ -128,7 +128,7 @@ uint32_t RsDirUtil::rs_CRC32(const unsigned char *data,uint32_t _len)
bool RsDirUtil::crc32File(FILE *fd, uint64_t file_size,uint32_t chunk_size, CRC32Map& crc_map) bool RsDirUtil::crc32File(FILE *fd, uint64_t file_size,uint32_t chunk_size, CRC32Map& crc_map)
{ {
if(fseek(fd,0,SEEK_SET) != 0) if(fseeko64(fd,0,SEEK_SET) != 0)
{ {
std::cerr << "crc32File(): cannot fseek to beginnign of the file !!" << std::endl ; std::cerr << "crc32File(): cannot fseek to beginnign of the file !!" << std::endl ;
return false ; return false ;
@ -545,9 +545,9 @@ bool RsDirUtil::getFileHash(const std::string& filepath, std::string &hash, uint
#endif #endif
/* determine size */ /* determine size */
fseek(fd, 0, SEEK_END); fseeko64(fd, 0, SEEK_END);
size = ftell(fd); size = ftello64(fd);
fseek(fd, 0, SEEK_SET); fseeko64(fd, 0, SEEK_SET);
SHA1_Init(sha_ctx); SHA1_Init(sha_ctx);
while((len = fread(gblBuf,1, 512, fd)) > 0) while((len = fread(gblBuf,1, 512, fd)) > 0)
@ -1000,9 +1000,9 @@ bool RsDirUtil::getWideFileHash(std::wstring filepath,
/***** XXX TO MAKE WIDE SYSTEM CALL ******************************************************/ /***** XXX TO MAKE WIDE SYSTEM CALL ******************************************************/
/* determine size */ /* determine size */
fseek(fd, 0, SEEK_END); fseeko64(fd, 0, SEEK_END);
size = ftell(fd); size = ftello64(fd);
fseek(fd, 0, SEEK_SET); fseeko64(fd, 0, SEEK_SET);
SHA1_Init(sha_ctx); SHA1_Init(sha_ctx);
while((len = fread(gblBuf,1, 512, fd)) > 0) while((len = fread(gblBuf,1, 512, fd)) > 0)