Improve ratings dialog to allow only valid values (#2199).
[dcpomatic.git] / src / lib / cross_windows.cc
index a425186f1816d88cf4b3559ad64c1514245a8b12..324b8cd8bd5cab03e3eb59266f7fbb2ea12f499a 100644 (file)
@@ -44,7 +44,9 @@ extern "C" {
 #include <fileapi.h>
 #undef DATADIR
 #include <shlwapi.h>
+#include <shlobj.h>
 #include <shellapi.h>
+#include <knownfolders.h>
 #include <fcntl.h>
 #include <fstream>
 #include <map>
@@ -208,16 +210,9 @@ resources_path ()
 
 
 boost::filesystem::path
-xsd_path ()
+libdcp_resources_path ()
 {
-       return directory_containing_executable().parent_path() / "xsd";
-}
-
-
-boost::filesystem::path
-tags_path ()
-{
-       return directory_containing_executable().parent_path() / "tags";
+       return resources_path ();
 }
 
 
@@ -397,7 +392,17 @@ maybe_open_console ()
 boost::filesystem::path
 home_directory ()
 {
-       return boost::filesystem::path(getenv("userprofile"));
+       PWSTR wide_path;
+       auto result = SHGetKnownFolderPath(FOLDERID_Documents, 0, nullptr, &wide_path);
+
+       if (result != S_OK) {
+               CoTaskMemFree(wide_path);
+               return boost::filesystem::path("c:\\");
+       }
+
+       auto path = wchar_to_utf8(wide_path);
+       CoTaskMemFree(wide_path);
+       return path;
 }