Various alignment tidying/fixups.
[dcpomatic.git] / src / lib / cross_windows.cc
index d97550ca9730aae138516619dc2d9173ff31acf3..b3d9a1558add1fbd2f7e70a74a23b2017accc985 100644 (file)
@@ -19,6 +19,8 @@
 */
 
 
+#define UNICODE 1
+
 #include "cross.h"
 #include "compose.hpp"
 #include "log.h"
@@ -252,7 +254,12 @@ boost::filesystem::path
 fix_long_path (boost::filesystem::path long_path)
 {
        using namespace boost::filesystem;
+
        path fixed = "\\\\?\\";
+       if (boost::algorithm::starts_with(long_path.string(), fixed.string())) {
+               return long_path;
+       }
+
        /* We have to make the path canonical but we can't call canonical() on the long path
         * as it will fail.  So we'll sort of do it ourselves (possibly badly).
         */
@@ -387,7 +394,7 @@ maybe_open_console ()
 boost::filesystem::path
 home_directory ()
 {
-       return boost::filesystem::path(getenv("HOMEDRIVE")) / boost::filesystem::path(getenv("HOMEPATH"));
+       return boost::filesystem::path(getenv("userprofile"));
 }
 
 
@@ -665,11 +672,14 @@ Drive::unmount ()
 
 
 boost::filesystem::path
-config_path ()
+config_path (optional<string> version)
 {
        boost::filesystem::path p;
        p /= g_get_user_config_dir ();
        p /= "dcpomatic2";
+       if (version) {
+               p /= *version;
+       }
        return p;
 }
 
@@ -689,3 +699,13 @@ dcpomatic::get_process_id ()
        return dcp::raw_convert<string>(GetCurrentProcessId());
 }
 
+
+bool
+show_in_file_manager (boost::filesystem::path, boost::filesystem::path select)
+{
+       std::wstringstream args;
+       args << "/select," << select;
+       auto const r = ShellExecute (0, L"open", L"explorer.exe", args.str().c_str(), 0, SW_SHOWDEFAULT);
+       return (reinterpret_cast<int64_t>(r) <= 32);
+}
+