From 66dbea0aaa28ba7c31a9f512c0be37eb094c4056 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 30 May 2000 20:44:17 +0000 Subject: [PATCH] Initial revision. --- src/Lib/Win32/mkdir.cpp | 46 +++++++++++++++++++++++++++++++++++++++++ src/Lib/Win32/mkdir.hpp | 11 ++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/Lib/Win32/mkdir.cpp create mode 100644 src/Lib/Win32/mkdir.hpp diff --git a/src/Lib/Win32/mkdir.cpp b/src/Lib/Win32/mkdir.cpp new file mode 100644 index 00000000..81066b1e --- /dev/null +++ b/src/Lib/Win32/mkdir.cpp @@ -0,0 +1,46 @@ +/* + * file: mkdir.cpp + */ +#include "simgear/config.h" +#include "simgear/compiler.h" + +#include +#include +#include +#include + +using namespace std; + +static char SEP[] = "/\\"; + +void fg_mkdir( const char *path ) +{ + + char *r, *token, tmp_path[256]; + string dir; + struct _finddata_t de; + //struct stat stat_buf; + + strcpy( tmp_path, path ); + r = strchr( SEP, path[0] ); // is first char a seperator? + token = strtok( tmp_path, SEP ); + if ( r != NULL ) + dir = --token; // include first char + else + dir = token; + + while ( token != NULL ) + { + //if ( stat( dir.c_str, &stat_buf) != 0 && errno == ENOENT ) + if ( _findfirst( dir.c_str(), &de ) == -1 && token[1] != ':' ) + { // does not exist - create it + mkdir( dir.c_str() ); + //printf( "mkdir %s\n", dir.c_str() ); + } // end if + token = strtok( NULL, SEP ); + if ( token != NULL ) + //dir = dir + DIR_SEP + token; + dir = dir + "/" + token; + } // end while + +} // end fg_mkdir diff --git a/src/Lib/Win32/mkdir.hpp b/src/Lib/Win32/mkdir.hpp new file mode 100644 index 00000000..8f5b4bdc --- /dev/null +++ b/src/Lib/Win32/mkdir.hpp @@ -0,0 +1,11 @@ +// +// file: mkdir.hpp +// + +#ifndef MY_MKDIR_H +#define MY_MKDIR_H + +// function prototypes +void fg_mkdir( const char* ); + +#endif