U++ framework
Do not panic. Ask here before giving up.

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: 1310
Registered: September 2007
Ultimate 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: 14291
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 May 30 15:53:34 GMT+2 2026

Total time taken to generate the page: 0.00584 seconds