]> git.tdb.fi Git - libs/core.git/blob - source/fs/windows/dir_location.cpp
Remove deprecated things
[libs/core.git] / source / fs / windows / dir_location.cpp
1 #include <shlobj.h>
2 #include <msp/core/application.h>
3 #include "dir.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace FS {
9
10 Path get_home_dir()
11 {
12         char home[MAX_PATH];
13         if(SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, home)==S_OK)
14                 return home;
15         return ".";
16 }
17
18 Path get_user_data_dir()
19 {
20         const string &appname = Application::get_name();
21         if(appname.empty())
22                 throw logic_error("no application name");
23
24         char datadir[MAX_PATH];
25         if(SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, 0, datadir)==S_OK)
26                 return Path(datadir)/appname;
27         return ".";
28 }
29
30 } // namespace FS
31 } // namespace Msp