]> git.tdb.fi Git - libs/core.git/blob - source/fs/windows/dir.cpp
Move most platform-specific code into overlay directories
[libs/core.git] / source / fs / windows / dir.cpp
1 #include <shlobj.h>
2 #include <msp/core/systemerror.h>
3 #include "dir.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace FS {
9
10 void mkdir(const Path &path, int)
11 {
12         if(!CreateDirectory(path.str().c_str(), NULL))
13                 throw system_error("CreateDirectory");
14 }
15
16 void rmdir(const Path &path)
17 {
18         if(!RemoveDirectory(path.str().c_str()))
19                 throw system_error("RemoveDirectory");
20 }
21
22 Path get_home_dir()
23 {
24         char home[MAX_PATH];
25         if(SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, home)==S_OK)
26                 return home;
27         return ".";
28 }
29
30 Path get_user_data_dir(const string &appname)
31 {
32         char datadir[MAX_PATH];
33         if(SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, 0, datadir)==S_OK)
34                 return Path(datadir)/appname;
35         return ".";
36 }
37
38 } // namespace FS
39 } // namespace Msp