mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-29 01:08:50 -04:00
Addition of next stage of new FileTransfer Code:
* Completed rough ftExtraList class (with Test Case) * Added data flow interface (ftData.h) * Added ftDataMultiplex (server + client modules). * Finished parts of ftcontroller / ftserver. * Minor Tweaks to ftTransferModules interface for compilation. Related Changes in other parts of the code: * Added new Job/Queue Thread Class. * Added more user-friendly directory functions. * Added FileInfo print operator. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@650 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a9bda83565
commit
79727897dd
19 changed files with 1245 additions and 106 deletions
|
@ -196,6 +196,31 @@ int RsDirUtil::breakupDirList(std::string path,
|
|||
|
||||
|
||||
|
||||
bool RsDirUtil::checkDirectory(std::string dir)
|
||||
{
|
||||
struct stat buf;
|
||||
int val = stat(dir.c_str(), &buf);
|
||||
if (val == -1)
|
||||
{
|
||||
#ifdef RSDIR_DEBUG
|
||||
std::cerr << "RsDirUtil::checkDirectory() ";
|
||||
std::cerr << dir << " doesn't exist" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
else if (!S_ISDIR(buf.st_mode))
|
||||
{
|
||||
// Some other type - error.
|
||||
#ifdef RSDIR_DEBUG
|
||||
std::cerr << "RsDirUtil::checkDirectory() ";
|
||||
std::cerr << dir << " is not Directory" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool RsDirUtil::checkCreateDirectory(std::string dir)
|
||||
{
|
||||
struct stat buf;
|
||||
|
@ -289,11 +314,24 @@ bool RsDirUtil::cleanupDirectory(std::string cleandir, std::list<std::string> k
|
|||
return true;
|
||||
}
|
||||
|
||||
/* slightly nicer helper function */
|
||||
bool RsDirUtil::hashFile(std::string filepath,
|
||||
std::string &name, std::string &hash, uint64_t &size)
|
||||
{
|
||||
if (getFileHash(filepath, hash, size))
|
||||
{
|
||||
/* extract file name */
|
||||
name = RsDirUtil::getTopDir(filepath);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
/* Function to hash, and get details of a file */
|
||||
bool RsDirUtil::getFileHash(std::string filepath,
|
||||
std::string &hash, uint64_t &size)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue