mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-29 08:37:36 -04:00
added an option to follow symbolic links or not, and anti-loop system during directories traversal
This commit is contained in:
parent
cf270d73c0
commit
5f69c9ea1f
13 changed files with 218 additions and 126 deletions
|
@ -480,6 +480,21 @@ bool RsDirUtil::checkCreateDirectory(const std::string& dir)
|
|||
}
|
||||
|
||||
|
||||
std::string RsDirUtil::removeSymLinks(const std::string& path)
|
||||
{
|
||||
#warning (Mr.Alice): I don't know how to do this on windows. See https://msdn.microsoft.com/en-us/library/windows/desktop/hh707084(v=vs.85).aspx
|
||||
#ifdef WINDOWS_SYS
|
||||
//if(!S_OK == PathCchCanonicalizeEx(tmp,...) ;
|
||||
return path ;
|
||||
#else
|
||||
char *tmp = canonicalize_file_name(path.c_str()) ;
|
||||
std::string result(tmp) ;
|
||||
|
||||
free(tmp);
|
||||
return result ;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RsDirUtil::cleanupDirectory(const std::string& cleandir, const std::set<std::string> &keepFiles)
|
||||
{
|
||||
for(librs::util::FolderIterator it(cleandir,false);it.isValid();it.next())
|
||||
|
|
|
@ -91,6 +91,10 @@ bool checkFile(const std::string& filename,uint64_t& file_size,bool disallow
|
|||
bool checkDirectory(const std::string& dir);
|
||||
bool checkCreateDirectory(const std::string& dir);
|
||||
|
||||
// Removes all symbolic links along the path and computes the actual location of the file/dir passed as argument.
|
||||
|
||||
std::string removeSymLinks(const std::string& path) ;
|
||||
|
||||
bool cleanupDirectory(const std::string& dir, const std::set<std::string> &keepFiles);
|
||||
bool cleanupDirectoryFaster(const std::string& dir, const std::set<std::string> &keepFiles);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue