View Single Post
Re: No Waypoints Save
Old
  (#5)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: No Waypoints Save - 24-01-2005

I had some code, there, hold on where is it...

ah here
Code:
// make output directory
length = strlen (output_file);
for (index = 0; index < length; index++)
	 if ((output_file[index] == '/') || (output_file[index] == '\\'))
	 {
		 strncpy (dirname, output_file, index);
		 dirname[index] = 0;
		 POSIX_mkdir (dirname, 666); // build each subdirectory recursively if needed
	 }
output_file is a full pathname
dirname must be a writable string
POSIX_mkdir is #defined like this:
Code:
#ifdef WIN32
#define POSIX_mkdir(a,b) _mkdir(a)
#else
#define POSIX_mkdir(a,b) mkdir(a,b)
#endif
That code will parse the path and call mkdir on each subdirectory recursively. If the directory already exists, it will leave it as is and mkdir will return ; if it doesn't exist, it will be created. This ensures you always have a correct path.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 24-01-2005 at 20:24..
  
Reply With Quote