#include <cstdlib>
#include <cerrno>
#include <dirent.h>
-#include <sys/stat.h>
#ifdef WIN32
#include <shlobj.h>
#else
#include <unistd.h>
+#include <sys/stat.h>
#endif
#include <msp/core/systemerror.h>
#include <msp/strings/regex.h>
void mkdir(const Path &path, int mode)
{
- int err;
#ifdef WIN32
- // The win32 version of this function doesn't take the mode argument. Go figure.
(void)mode;
- err = ::mkdir(path.str().c_str());
+ if(!CreateDirectory(path.str().c_str(), NULL))
+ throw system_error("CreateDirectory");
#else
- err = ::mkdir(path.str().c_str(), mode);
-#endif
-
- if(err==-1)
+ if(::mkdir(path.str().c_str(), mode)==-1)
throw system_error("mkdir");
+#endif
}
void mkpath(const Path &path, int mode)
void rmdir(const Path &path)
{
+#ifdef WIN32
+ if(!RemoveDirectory(path.str().c_str()))
+ throw system_error("RemoveDirectory");
+#else
if(::rmdir(path.str().c_str())==-1)
throw system_error("rmdir");
+#endif
}
void rmpath(const Path &path)