Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Small bug in DeleteFolderDeep
Small bug in DeleteFolderDeep [message #47652] Tue, 21 February 2017 20:24 Go to next message
mdelfede is currently offline  mdelfede
Messages: 1259
Registered: September 2007
Senior Contributor
Hi,

if a folder contains a symbolic link it doesn't get deleted; solution is to patch this
bool DeleteFolderDeep(const char *dir)
{
	{
		FindFile ff(AppendFileName(dir, "*.*"));
		while(ff) {
			String name = ff.GetName();
			String p = AppendFileName(dir, name);
			if(ff.IsFile())
				FileDelete(p);
			else
			if(ff.IsFolder())
				DeleteFolderDeep(p);
			ff.Next();
		}
	}
	return DirectoryDelete(dir);
}


to this

bool DeleteFolderDeep(const char *dir)
{
	{
		FindFile ff(AppendFileName(dir, "*.*"));
		while(ff) {
			String name = ff.GetName();
			String p = AppendFileName(dir, name);
			if(ff.IsFile() || ff.IsSymLink())
				FileDelete(p);
			else
			if(ff.IsFolder())
				DeleteFolderDeep(p);
			ff.Next();
		}
	}
	return DirectoryDelete(dir);
}


In order to have symlinks deleted too.

Ciao

Max
Re: Small bug in DeleteFolderDeep [message #47675 is a reply to message #47652] Thu, 02 March 2017 15:54 Go to previous message
mirek is currently offline  mirek
Messages: 12126
Registered: November 2005
Ultimate Member
Thanks, patch applied.
Previous Topic: Vector< Vector<int>> issue
Next Topic: Possible bug in LocalProcess
Goto Forum:
  


Current Time: Sat Dec 14 20:28:32 CET 2019

Total time taken to generate the page: 0.01016 seconds