11 #include <sys/stat.h> // stat()
12 #include <unistd.h> // stat()
16 #include <Bucket/bucketutils.h>
31 void ReplaceDivider( char* path )
33 char div = PathDivider()[0];
41 for ( i = 0; path[i]; i++ )
47 int Exists( char* path )
51 ReplaceDivider( path );
52 if ( path[strlen( path ) - 1] == ':' )
54 if ( _stat( path, &statbuff ) != 0 )
60 void CreateDir( char* path )
62 if ( ! path || ! strlen( path ) )
64 ReplaceDivider( path );
65 // see if the parent exists yet
66 int i; // looping index
67 string parent; // path to parent
70 for ( i = strlen( parent.c_str() )-1; i >= 0; i-- )
71 if ( parent[i] == PathDivider()[0] )
77 if ( ! Exists( parent.c_str() ) )
79 CreateDir( parent.c_str() );
82 if ( ! Exists( path ) )
84 if (mkdir(path, S_IRWXU) != 0 )
86 cout << "Could not create directory " << path << endl;
88 cout << "CreateDir: " << path << endl;
95 int main(int argc, char **argv)
101 cout << "Makedir failed needs one argument\n";
106 CreateDir(root.c_str());
112 int main(int argc, char **argv)
114 cout << "This program is intended to work with windoze\n";
115 cout << "Other platforms can use mkdir\n";