diff --git a/libretroshare/src/ft/ftdatamultiplex.cc b/libretroshare/src/ft/ftdatamultiplex.cc index 315c7b6f4..6c36c4114 100644 --- a/libretroshare/src/ft/ftdatamultiplex.cc +++ b/libretroshare/src/ft/ftdatamultiplex.cc @@ -489,12 +489,12 @@ bool ftDataMultiplex::doWork() return true; } -bool ftDataMultiplex::recvSingleChunkCrc(const std::string& /*peerId*/, const std::string& hash,uint32_t chunk_number,const Sha1CheckSum& crc) +bool ftDataMultiplex::recvSingleChunkCrc(const std::string& peerId, const std::string& hash,uint32_t chunk_number,const Sha1CheckSum& crc) { RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/ //#ifdef MPLEX_DEBUG - std::cerr << "ftDataMultiplex::recvSingleChunkCrc() Received crc of file " << hash << ", chunk " << chunk_number << ", crc=" << crc.toStdString() << std::endl; + std::cerr << "ftDataMultiplex::recvSingleChunkCrc() Received crc of file " << hash << ", from peer id " << peerId << ", chunk " << chunk_number << ", crc=" << crc.toStdString() << std::endl; //#endif std::map::iterator it = mClients.find(hash); @@ -757,7 +757,7 @@ bool ftDataMultiplex::computeAndSendCRC32Map(const std::string& peerId, const st std::cerr << "Computing CRC32Map for file " << filename << ", hash=" << hash << ", size=" << filesize << std::endl; - FILE *fd = fopen(filename.c_str(),"r") ; + FILE *fd = RsDirUtil::rs_fopen(filename.c_str(),"rb") ; if(fd == NULL) { @@ -899,7 +899,7 @@ bool ftDataMultiplex::handleRecvChunkCrcRequest(const std::string& peerId, const std::cerr << "Computing Sha1 for chunk " << chunk_number<< " of file " << filename << ", hash=" << hash << ", size=" << filesize << std::endl; unsigned char *buf = new unsigned char[ChunkMap::CHUNKMAP_FIXED_CHUNK_SIZE] ; - FILE *fd = fopen(filename.c_str(),"r") ; + FILE *fd = RsDirUtil::rs_fopen(filename.c_str(),"rb") ; if(fd == NULL) { diff --git a/libretroshare/src/tests/util/sha1_test.cc b/libretroshare/src/tests/util/sha1_test.cc index 811bd96eb..3af4c1829 100644 --- a/libretroshare/src/tests/util/sha1_test.cc +++ b/libretroshare/src/tests/util/sha1_test.cc @@ -47,7 +47,7 @@ int main(int argc,char *argv[]) return -1 ; } - FILE *f = fopen(argv[1],"r") ; + FILE *f = RsDirUtil::rs_fopen(argv[1],"r") ; if(f == NULL) { @@ -75,6 +75,19 @@ int main(int argc,char *argv[]) Sha1CheckSum H(hash) ; std::cerr << "Hashed transformed: " << H.toStdString() << std::endl; + std::cerr << "Computing all chunk hashes:" << std::endl; + + fseek(f,0,SEEK_SET) ; + int n=0 ; + + while(len = fread(buf,1,SIZE,f)) + { + Sha1CheckSum sum = RsDirUtil::sha1sum(buf,len) ; + std::cerr << "Chunk " << n << ": " << sum.toStdString() << std::endl; + n++; + } + + fclose(f) ; return 0 ; }