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

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

ah here
// 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:
#ifdef WIN32
#define POSIX_mkdir(a,b) _mkdir(a)
#define POSIX_mkdir(a,b) mkdir(a,b)
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 19:24..
Reply With Quote