-int mkpath(const Path &path, int mode)
-{
- Path p;
- for(Path::iterator i=path.begin(); i!=path.end(); ++i)
- {
- p/=*i;
-#ifdef WIN32
- if(p.size()==1 && is_windows_drive(*i)) continue;
-#endif
- struct stat st;
- int err=stat(p.str().c_str(),&st);
- if(err==0)
- {
- if(!S_ISDIR(st.st_mode))
- {
- errno=EEXIST;
- return -1;
- }
- continue;
- }
- else if(errno!=ENOENT)
- return -1;
- else
- {
-#ifdef WIN32
- // The win32 version of this function doesn't take the mode argument. Go figure.
- err=mkdir(p.str().c_str());
-#else
- err=mkdir(p.str().c_str(),mode);
-#endif
- if(err==-1) return -1;
- }
- }
-
- return 0;
-}
-
-int rmdir(const Path &path, bool recursive)