2 #include <msp/core/mutex.h>
3 #include <msp/core/systemerror.h>
11 void mkdir(const Path &path, int)
13 if(!CreateDirectory(path.str().c_str(), NULL))
14 throw system_error("CreateDirectory");
17 void rmdir(const Path &path)
19 if(!RemoveDirectory(path.str().c_str()))
20 throw system_error("RemoveDirectory");
23 /* Windows documentation says Get/SetCurrentDirectory use a global buffer and
24 are not thread safe. */
25 static Mutex &cwd_mutex()
33 MutexLock lock(cwd_mutex());
37 DWORD len = GetCurrentDirectory(sizeof(buf), buf);
40 vector<char> buf2(len+1);
41 len = GetCurrentDirectory(buf2.size(), buf2.data());
48 throw system_error("GetCurrentDirectory");
53 void chdir(const Path &path)
55 MutexLock lock(cwd_mutex());
56 if(!SetCurrentDirectory(path.c_str()))
57 throw system_error("SetCurrentDirectory");