1 #include <ctype.h> // isspace()
2 #include <stdlib.h> // atoi()
3 #include <math.h> // rint()
6 #include <sys/stat.h> // stat()
7 #include <unistd.h> // stat()
11 #include <Bucket/bucketutils.h>
14 # define MKDIR(a) mkdir(a,S_IRWXU) // I am just guessing at this flag
16 #endif // __CYGWIN32__
20 // return the file path name ( foo/bar/file.ext = foo/bar )
21 static void extract_path (char *in, char *base) {
28 while ( (i >= 0) && (in[i] != '/') ) {
36 // Make a subdirectory
37 static int my_mkdir (char *dir) {
43 result = stat (dir, &stat_buf);
47 result = stat (dir, &stat_buf);
49 printf ("problem creating %s\n", dir);
51 printf ("%s created\n", dir);
54 printf ("%s already exists\n", dir);
60 #endif // __CYGWIN32__
63 void scenery_dir( const string& dir ) {
65 char base_path[256], file[256], exfile[256];
74 cout << "Dir = " + dir + "\n";
76 // stat() directory and create if needed
77 result = stat(dir.c_str(), &stat_buf);
79 cout << "Stat error need to create directory\n";
83 command = "mkdir -p " + dir + "\n";
84 system( command.c_str() );
88 // Cygwin crashes when trying to output to node file
89 // explicitly making directory structure seems OK on Win95
91 extract_path (base_path, tmp_path);
94 if (my_mkdir ( dir.c_str() )) { exit (-1); }
97 if (my_mkdir ( dir.c_str() )) { exit (-1); }
99 #endif // __CYGWIN32__
102 // assume directory exists
103 cout << " Allready Exists !\n";
107 int main(int argc, char **argv)
113 cout << "Makedir failed\n";