2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* "$Id: rsdir.h,v 1.1 2007-02-19 20:08:30 rmf24 Exp $"
|
|
|
|
*
|
|
|
|
* RetroShare C++ Interface.
|
|
|
|
*
|
|
|
|
* Copyright 2004-2007 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef RSUTIL_DIRFNS_H
|
|
|
|
#define RSUTIL_DIRFNS_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
2009-05-11 10:30:53 -04:00
|
|
|
#include <stdint.h>
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2011-03-03 18:30:08 -05:00
|
|
|
class RsThread;
|
2010-07-21 19:14:10 -04:00
|
|
|
|
2012-03-15 15:55:43 -04:00
|
|
|
#include <retroshare/rstypes.h>
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
namespace RsDirUtil {
|
|
|
|
|
2010-10-01 16:05:09 -04:00
|
|
|
std::string getTopDir(const std::string&);
|
|
|
|
std::string getRootDir(const std::string&);
|
|
|
|
std::string removeRootDir(const std::string& path);
|
|
|
|
std::string removeTopDir(const std::string& dir);
|
|
|
|
std::string removeRootDirs(const std::string& path, const std::string& root);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-03-29 09:58:28 -04:00
|
|
|
// Renames file from to file to. Files should be on the same file system.
|
|
|
|
// returns true if succeed, false otherwise.
|
|
|
|
bool renameFile(const std::string& from,const std::string& to) ;
|
2011-08-14 18:31:05 -04:00
|
|
|
//bool createBackup (const std::string& sFilename, unsigned int nCount = 5);
|
2009-03-29 09:58:28 -04:00
|
|
|
|
2010-07-21 19:14:10 -04:00
|
|
|
// returns the CRC32 of the data of length len
|
|
|
|
//
|
2010-07-06 01:04:11 -04:00
|
|
|
uint32_t rs_CRC32(const unsigned char *data,uint32_t len) ;
|
|
|
|
|
2010-07-21 19:14:10 -04:00
|
|
|
// Computes the CRC32 map of a complete file, with given size and chunk size.
|
|
|
|
//
|
|
|
|
bool crc32File(FILE *f,uint64_t file_size,uint32_t chunk_size,CRC32Map& map) ;
|
|
|
|
|
2010-10-01 16:05:09 -04:00
|
|
|
int breakupDirList(const std::string& path, std::list<std::string> &subdirs);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-10-28 18:59:46 -04:00
|
|
|
bool copyFile(const std::string& source,const std::string& dest);
|
|
|
|
bool checkFile(const std::string& filename);
|
2010-10-01 16:05:09 -04:00
|
|
|
bool checkDirectory(const std::string& dir);
|
|
|
|
bool checkCreateDirectory(const std::string& dir);
|
2010-12-21 08:30:45 -05:00
|
|
|
bool cleanupDirectory(const std::string& dir, const std::list<std::string> &keepFiles);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2011-02-14 14:59:06 -05:00
|
|
|
bool hashFile(const std::string& filepath, std::string &name, std::string &hash, uint64_t &size);
|
2011-03-03 18:30:08 -05:00
|
|
|
bool getFileHash(const std::string& filepath,std::string &hash, uint64_t &size, RsThread *thread = NULL);
|
2008-03-17 09:51:04 -04:00
|
|
|
|
2012-03-15 15:55:43 -04:00
|
|
|
Sha1CheckSum sha1sum(uint8_t *data,uint32_t size) ;
|
|
|
|
|
2009-09-08 16:18:43 -04:00
|
|
|
|
|
|
|
std::wstring getWideTopDir(std::wstring);
|
|
|
|
std::wstring getWideRootDir(std::wstring);
|
|
|
|
std::wstring removeWideRootDir(std::wstring path);
|
|
|
|
std::wstring removeWideTopDir(std::wstring dir);
|
|
|
|
std::wstring removeWideRootDirs(std::wstring path, std::wstring root);
|
|
|
|
|
|
|
|
// Renames file from to file to. Files should be on the same file system.
|
|
|
|
// returns true if succeed, false otherwise.
|
|
|
|
bool renameWideFile(const std::wstring& from,const std::wstring& to) ;
|
|
|
|
|
|
|
|
int breakupWideDirList(std::wstring path,
|
|
|
|
std::list<std::wstring> &subdirs);
|
|
|
|
|
|
|
|
bool checkWideDirectory(std::wstring dir);
|
|
|
|
bool checkWideCreateDirectory(std::wstring dir);
|
|
|
|
bool cleanupWideDirectory(std::wstring dir, std::list<std::wstring> keepFiles);
|
|
|
|
|
|
|
|
bool hashWideFile(std::wstring filepath,
|
|
|
|
std::wstring &name, std::string &hash, uint64_t &size);
|
|
|
|
|
|
|
|
bool getWideFileHash(std::wstring filepath,
|
|
|
|
std::string &hash, uint64_t &size);
|
|
|
|
|
2011-04-03 19:11:38 -04:00
|
|
|
FILE *rs_fopen(const char* filename, const char* mode);
|
2011-05-15 08:42:55 -04:00
|
|
|
|
|
|
|
std::string convertPathToUnix(std::string path);
|
|
|
|
std::string makePath(const std::string &path1, const std::string &path2);
|
2008-06-05 18:10:28 -04:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|