]> git.tdb.fi Git - libs/core.git/blob - source/fs/windows/dir_location.cpp
Fix references to deprecated functions
[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(const string &)
19 {
20         return get_user_data_dir();
21 }
22
23 Path get_user_data_dir()
24 {
25         const string &appname = Application::get_name();
26         if(appname.empty())
27                 throw logic_error("no application name");
28
29         char datadir[MAX_PATH];
30         if(SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, 0, datadir)==S_OK)
31                 return Path(datadir)/appname;
32         return ".";
33 }
34
35 } // namespace FS
36 } // namespace Msp