added large file support

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1575 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-08-29 18:55:13 +00:00
parent 70a5cbf107
commit 2597e6a61e
3 changed files with 27 additions and 16 deletions

View File

@ -26,6 +26,7 @@
#include "serialiser/rsserviceids.h" #include "serialiser/rsserviceids.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rsnotify.h" #include "rsiface/rsnotify.h"
#include <errno.h>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
@ -392,15 +393,18 @@ void FileIndexMonitor::updateCycle()
*/ */
struct dirent *dent; struct dirent *dent;
struct stat buf; struct stat64 buf;
while(NULL != (dent = readdir(dir))) while(NULL != (dent = readdir(dir)))
{ {
/* check entry type */ /* check entry type */
std::string fname = dent -> d_name; std::string fname = dent -> d_name;
std::string fullname = realpath + "/" + fname; std::string fullname = realpath + "/" + fname;
#ifdef FIM_DEBUG
std::cerr << "calling stats on " << fullname <<std::endl;
#endif
if (-1 != stat(fullname.c_str(), &buf)) if (-1 != stat64(fullname.c_str(), &buf))
{ {
#ifdef FIM_DEBUG #ifdef FIM_DEBUG
std::cerr << "buf.st_mode: " << buf.st_mode <<std::endl; std::cerr << "buf.st_mode: " << buf.st_mode <<std::endl;
@ -488,6 +492,10 @@ void FileIndexMonitor::updateCycle()
continue; continue;
} }
} }
#ifdef FIM_DEBUG
else
std::cout << "stat error " << errno << std::endl ;
#endif
} }
@ -917,7 +925,7 @@ bool FileIndexMonitor::hashFile(std::string fullpath, FileEntry &fent)
#ifdef FIM_DEBUG #ifdef FIM_DEBUG
std::cerr << "File to hash = " << f_hash << std::endl; std::cerr << "File to hash = " << f_hash << std::endl;
#endif #endif
if (NULL == (fd = fopen(f_hash.c_str(), "rb"))) return false; if (NULL == (fd = fopen64(f_hash.c_str(), "rb"))) return false;
SHA1_Init(sha_ctx); SHA1_Init(sha_ctx);
while((len = fread(gblBuf,1, 512, fd)) > 0) while((len = fread(gblBuf,1, 512, fd)) > 0)
@ -928,6 +936,9 @@ bool FileIndexMonitor::hashFile(std::string fullpath, FileEntry &fent)
/* reading failed for some reason */ /* reading failed for some reason */
if (ferror(fd)) if (ferror(fd))
{ {
#ifdef FIM_DEBUG
std::cerr << "read error !!" << std::endl;
#endif
delete sha_ctx; delete sha_ctx;
fclose(fd); fclose(fd);
return false; return false;

View File

@ -94,14 +94,14 @@ bool ftFileCreator::addFileData(uint64_t offset, uint32_t chunk_size, void *data
/* /*
* go to the offset of the file * 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; std::cerr << "ftFileCreator::addFileData() Bad fseek" << std::endl;
return 0; return 0;
} }
long int pos; uint64_t pos;
pos = ftell(fd); pos = ftello64(fd);
/* /*
* add the data * add the data
*/ */
@ -117,7 +117,7 @@ bool ftFileCreator::addFileData(uint64_t offset, uint32_t chunk_size, void *data
return 0; return 0;
} }
pos = ftell(fd); pos = ftello64(fd);
#ifdef FILE_DEBUG #ifdef FILE_DEBUG
std::cerr << "ftFileCreator::addFileData() added Data..."; std::cerr << "ftFileCreator::addFileData() added Data...";
@ -166,7 +166,7 @@ int ftFileCreator::initializeFileAttrs()
* attempt to open file * attempt to open file
*/ */
fd = fopen(file_name.c_str(), "r+b"); fd = fopen64(file_name.c_str(), "r+b");
if (!fd) if (!fd)
{ {
std::cerr << "ftFileCreator::initializeFileAttrs() Failed to open (r+b): "; std::cerr << "ftFileCreator::initializeFileAttrs() Failed to open (r+b): ";
@ -176,7 +176,7 @@ int ftFileCreator::initializeFileAttrs()
std::cerr << std::endl; std::cerr << std::endl;
/* try opening for write */ /* try opening for write */
fd = fopen(file_name.c_str(), "w+b"); fd = fopen64(file_name.c_str(), "w+b");
if (!fd) if (!fd)
{ {
std::cerr << "ftFileCreator::initializeFileAttrs()"; std::cerr << "ftFileCreator::initializeFileAttrs()";
@ -193,13 +193,13 @@ int ftFileCreator::initializeFileAttrs()
* move to the end * 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; std::cerr << "ftFileCreator::initializeFileAttrs() Seek Failed" << std::endl;
return 0; return 0;
} }
uint64_t recvdsize = ftell(fd); uint64_t recvdsize = ftello64(fd);
std::cerr << "ftFileCreator::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl; std::cerr << "ftFileCreator::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;

View File

@ -113,7 +113,7 @@ bool ftFileProvider::getFileData(uint64_t offset, uint32_t &chunk_size, void *da
/* /*
* seek for base_loc * seek for base_loc
*/ */
fseek(fd, base_loc, SEEK_SET); fseeko64(fd, base_loc, SEEK_SET);
// Data space allocated by caller. // Data space allocated by caller.
//void *data = malloc(chunk_size); //void *data = malloc(chunk_size);
@ -191,14 +191,14 @@ int ftFileProvider::initializeFileAttrs()
* attempt to open file * attempt to open file
*/ */
fd = fopen(file_name.c_str(), "rb"); fd = fopen64(file_name.c_str(), "rb");
if (!fd) if (!fd)
{ {
std::cerr << "ftFileProvider::initializeFileAttrs() Failed to open (r+b): "; std::cerr << "ftFileProvider::initializeFileAttrs() Failed to open (r+b): ";
std::cerr << file_name << std::endl; std::cerr << file_name << std::endl;
/* try opening read only */ /* try opening read only */
fd = fopen(file_name.c_str(), "rb"); fd = fopen64(file_name.c_str(), "rb");
if (!fd) if (!fd)
{ {
std::cerr << "ftFileProvider::initializeFileAttrs() Failed to open (rb): "; std::cerr << "ftFileProvider::initializeFileAttrs() Failed to open (rb): ";
@ -214,13 +214,13 @@ int ftFileProvider::initializeFileAttrs()
* move to the end * 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; std::cerr << "ftFileProvider::initializeFileAttrs() Seek Failed" << std::endl;
return 0; return 0;
} }
uint64_t recvdsize = ftell(fd); uint64_t recvdsize = ftello64(fd);
std::cerr << "ftFileProvider::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl; std::cerr << "ftFileProvider::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;