View Single Post
Re: No Waypoints Save
Council Member
Rick's Avatar
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: No Waypoints Save - 24-01-2005

Originally Posted by Pierre-Marie Baty
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.
Nice one
Meh I keep including pieces of code made by you
Reply With Quote