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 » Developing U++ » UppHub » DirectoryCreateMulti as an alternative for RealizeDirectory
Re: DirectoryCreateMulti as an alternative for RealizeDirectory [message #19557 is a reply to message #19553] Mon, 15 December 2008 15:59 Go to previous messageGo to previous message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
luzr wrote on Mon, 15 December 2008 13:42

OK, I have ended with this code

#ifdef POSIX
void RealizeDirectory(String dir, int mode)
#else
void RealizeDirectory(String dir)
#endif
{
	Vector<String> p;
	while(dir.GetLength() > DIR_MIN) {
		p.Add(dir);
		dir = GetFileFolder(dir);
	}
	for(int i = p.GetCount() - 1; i >= 0; i--)
		if(!DirectoryExists(p[i]))
#ifdef POSIX
			DirectoryCreate(p[i], mode);
#else
			DirectoryCreate(p[i]);
#endif
}


This is definitely a step in the right direction Smile

Mirek

Without NormalizePath function your code still not working with "a\b\c" directory. As stated in the comments:
#ifdef PLATFORM_WIN32
#define DIR_MIN 3 //!! wrong! what about \a\b\c ?
#endif

This is my intention.
It's not wrong with recursion, if they not too long for the stack overflow Wink. I think it's not a problem (MAX_PATH == 260 in the stdlib.h).
So, you prefer:
dir.GetLength() > DIR_MIN

I use another more adequate method (in my opinion of course):
i>0 && path[i - 1] != ':'

To note:
- DirectoryCreate returns variable about success of directory creation. DirectoryCreateMulti do this also.
- DirectoryCreateMulti doesn't keep all directories for verification of existent directory. They use backward search with ReverseFind function.

[Updated on: Mon, 15 December 2008 16:53]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Added Signals package
Next Topic: Cairo
Goto Forum:
  


Current Time: Sun May 12 00:07:30 CEST 2024

Total time taken to generate the page: 0.02354 seconds