]> git.mxchange.org Git - flightgear.git/commitdiff
Initial revision.
authorcurt <curt>
Fri, 2 Oct 1998 21:40:56 +0000 (21:40 +0000)
committercurt <curt>
Fri, 2 Oct 1998 21:40:56 +0000 (21:40 +0000)
Makedir/Makefile.am [new file with mode: 0644]
Makedir/makedir.cxx [new file with mode: 0644]

diff --git a/Makedir/Makefile.am b/Makedir/Makefile.am
new file mode 100644 (file)
index 0000000..c836722
--- /dev/null
@@ -0,0 +1,7 @@
+bin_PROGRAMS = makedir
+
+makedir_SOURCES = makedir.cxx
+
+makedir_LDADD = $(top_builddir)/Lib/Bucket/libBucket.a
+
+INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib
diff --git a/Makedir/makedir.cxx b/Makedir/makedir.cxx
new file mode 100644 (file)
index 0000000..96563cf
--- /dev/null
@@ -0,0 +1,120 @@
+#include <ctype.h>    // isspace()
+#include <stdlib.h>   // atoi()
+#include <math.h>     // rint()
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h> // stat()
+#include <unistd.h>   // stat()
+
+#include <string>
+
+#include <Bucket/bucketutils.h>
+
+#ifdef __CYGWIN32__
+#  define MKDIR(a) mkdir(a,S_IRWXU)     // I am just guessing at this flag
+(NHV)
+#endif // __CYGWIN32__
+
+#ifdef __CYGWIN32__
+
+// return the file path name ( foo/bar/file.ext = foo/bar )
+static void extract_path (char *in, char *base) {
+    int len, i;
+
+    len = strlen (in);
+    strcpy (base, in);
+
+    i = len - 1;
+    while ( (i >= 0) && (in[i] != '/') ) {
+       i--;
+    }
+
+    base[i] = '\0';
+}
+
+
+// Make a subdirectory
+static int my_mkdir (char *dir) {
+    struct stat stat_buf;
+    int result;
+
+    printf ("mk_dir() ");
+
+    result = stat (dir, &stat_buf);
+
+    if (result != 0) {
+       MKDIR (dir);
+       result = stat (dir, &stat_buf);
+       if (result != 0) {
+           printf ("problem creating %s\n", dir);
+       } else {
+           printf ("%s created\n", dir);
+       }
+    } else {
+       printf ("%s already exists\n", dir);
+    }
+
+    return (result);
+}
+
+#endif // __CYGWIN32__
+
+
+void scenery_dir( const string& dir ) {
+    struct stat stat_buf;
+    char base_path[256], file[256], exfile[256];
+#ifdef __CYGWIN32__
+    char tmp_path[256];
+#endif
+    string command;
+    FILE *fd;
+       fgBUCKET p;
+       int result;
+
+    cout << "Dir = " + dir + "\n";
+
+    // stat() directory and create if needed
+    result = stat(dir.c_str(), &stat_buf);
+    if ( result != 0 ) {
+       cout << "Stat error need to create directory\n";
+
+#ifndef __CYGWIN32__
+
+       command = "mkdir -p " + dir + "\n";
+       system( command.c_str() );
+
+#else // __CYGWIN32__
+
+       // Cygwin crashes when trying to output to node file
+       // explicitly making directory structure seems OK on Win95
+
+       extract_path (base_path, tmp_path);
+
+       dir = tmp_path;
+       if (my_mkdir ( dir.c_str() )) { exit (-1); }
+
+       dir = base_path;
+       if (my_mkdir ( dir.c_str() )) { exit (-1); }
+
+#endif // __CYGWIN32__
+
+    } else {
+       // assume directory exists
+               cout << "  Allready Exists !\n";
+    }
+}
+
+int main(int argc, char **argv)
+{
+       string root;
+
+       if(argc != 2)
+       {
+               cout << "Makedir failed\n";
+               return(10);
+       }
+       root = argv[1];
+       scenery_dir(root);
+
+       return(0);
+}