From 2597e6a61e4c19a5dc091da20fc991fca77bedca Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 29 Aug 2009 18:55:13 +0000 Subject: [PATCH] added large file support git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1575 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/dbase/fimonitor.cc | 17 ++++++++++++++--- libretroshare/src/ft/ftfilecreator.cc | 16 ++++++++-------- libretroshare/src/ft/ftfileprovider.cc | 10 +++++----- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/libretroshare/src/dbase/fimonitor.cc b/libretroshare/src/dbase/fimonitor.cc index 3bac54733..d0ca9c953 100644 --- a/libretroshare/src/dbase/fimonitor.cc +++ b/libretroshare/src/dbase/fimonitor.cc @@ -26,6 +26,7 @@ #include "serialiser/rsserviceids.h" #include "rsiface/rsiface.h" #include "rsiface/rsnotify.h" +#include #include #include @@ -392,15 +393,18 @@ void FileIndexMonitor::updateCycle() */ struct dirent *dent; - struct stat buf; + struct stat64 buf; while(NULL != (dent = readdir(dir))) { /* check entry type */ std::string fname = dent -> d_name; std::string fullname = realpath + "/" + fname; +#ifdef FIM_DEBUG + std::cerr << "calling stats on " << fullname < 0) @@ -928,6 +936,9 @@ bool FileIndexMonitor::hashFile(std::string fullpath, FileEntry &fent) /* reading failed for some reason */ if (ferror(fd)) { +#ifdef FIM_DEBUG + std::cerr << "read error !!" << std::endl; +#endif delete sha_ctx; fclose(fd); return false; diff --git a/libretroshare/src/ft/ftfilecreator.cc b/libretroshare/src/ft/ftfilecreator.cc index 14293cf5f..255f0f7e5 100644 --- a/libretroshare/src/ft/ftfilecreator.cc +++ b/libretroshare/src/ft/ftfilecreator.cc @@ -94,14 +94,14 @@ bool ftFileCreator::addFileData(uint64_t offset, uint32_t chunk_size, void *data /* * go to the offset of the file */ - if (0 != fseek(this->fd, offset, SEEK_SET)) + if (0 != fseeko64(this->fd, offset, SEEK_SET)) { std::cerr << "ftFileCreator::addFileData() Bad fseek" << std::endl; return 0; } - long int pos; - pos = ftell(fd); + uint64_t pos; + pos = ftello64(fd); /* * add the data */ @@ -117,7 +117,7 @@ bool ftFileCreator::addFileData(uint64_t offset, uint32_t chunk_size, void *data return 0; } - pos = ftell(fd); + pos = ftello64(fd); #ifdef FILE_DEBUG std::cerr << "ftFileCreator::addFileData() added Data..."; @@ -166,7 +166,7 @@ int ftFileCreator::initializeFileAttrs() * attempt to open file */ - fd = fopen(file_name.c_str(), "r+b"); + fd = fopen64(file_name.c_str(), "r+b"); if (!fd) { std::cerr << "ftFileCreator::initializeFileAttrs() Failed to open (r+b): "; @@ -176,7 +176,7 @@ int ftFileCreator::initializeFileAttrs() std::cerr << std::endl; /* try opening for write */ - fd = fopen(file_name.c_str(), "w+b"); + fd = fopen64(file_name.c_str(), "w+b"); if (!fd) { std::cerr << "ftFileCreator::initializeFileAttrs()"; @@ -193,13 +193,13 @@ int ftFileCreator::initializeFileAttrs() * move to the end */ - if (0 != fseek(fd, 0L, SEEK_END)) + if (0 != fseeko64(fd, 0L, SEEK_END)) { std::cerr << "ftFileCreator::initializeFileAttrs() Seek Failed" << std::endl; return 0; } - uint64_t recvdsize = ftell(fd); + uint64_t recvdsize = ftello64(fd); std::cerr << "ftFileCreator::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl; diff --git a/libretroshare/src/ft/ftfileprovider.cc b/libretroshare/src/ft/ftfileprovider.cc index 8ed176cc6..d57036c2c 100644 --- a/libretroshare/src/ft/ftfileprovider.cc +++ b/libretroshare/src/ft/ftfileprovider.cc @@ -113,7 +113,7 @@ bool ftFileProvider::getFileData(uint64_t offset, uint32_t &chunk_size, void *da /* * seek for base_loc */ - fseek(fd, base_loc, SEEK_SET); + fseeko64(fd, base_loc, SEEK_SET); // Data space allocated by caller. //void *data = malloc(chunk_size); @@ -191,14 +191,14 @@ int ftFileProvider::initializeFileAttrs() * attempt to open file */ - fd = fopen(file_name.c_str(), "rb"); + fd = fopen64(file_name.c_str(), "rb"); if (!fd) { std::cerr << "ftFileProvider::initializeFileAttrs() Failed to open (r+b): "; std::cerr << file_name << std::endl; /* try opening read only */ - fd = fopen(file_name.c_str(), "rb"); + fd = fopen64(file_name.c_str(), "rb"); if (!fd) { std::cerr << "ftFileProvider::initializeFileAttrs() Failed to open (rb): "; @@ -214,13 +214,13 @@ int ftFileProvider::initializeFileAttrs() * move to the end */ - if (0 != fseek(fd, 0L, SEEK_END)) + if (0 != fseeko64(fd, 0L, SEEK_END)) { std::cerr << "ftFileProvider::initializeFileAttrs() Seek Failed" << std::endl; return 0; } - uint64_t recvdsize = ftell(fd); + uint64_t recvdsize = ftello64(fd); std::cerr << "ftFileProvider::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;