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.