swaroop: fall back to home directory if the content directory is not present.
authorCarl Hetherington <cth@carlh.net>
Fri, 14 Dec 2018 20:35:58 +0000 (20:35 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 14 Dec 2018 20:35:58 +0000 (20:35 +0000)
src/lib/cross.cc
src/lib/cross.h
src/wx/content_view.cc

index 61b150a3b68fe05526a8a81aa60ff024a414cc6c..b9b2153030d81dc66f63382101f0c1f4848c3c15 100644 (file)
@@ -463,3 +463,14 @@ maybe_open_console ()
        }
 }
 #endif
+
+boost::filesystem::path
+home_directory ()
+{
+#if defined(DCPOMATIC_LINUX) || defined(DCPOMATIC_OSX)
+               return getenv("HOME");
+#endif
+#ifdef DCPOMATIC_WINDOWS
+               return getenv("HOMEDRIVE") / getenv("HOMEPATH");
+#endif
+}
index cd0372338fc062ec3e5a4fce4a631f52f119b0d1..ee5e7919a8191c1297afb5170850fe83c0ba7558 100644 (file)
@@ -55,6 +55,7 @@ extern void start_batch_converter (boost::filesystem::path dcpomatic);
 extern void start_player (boost::filesystem::path dcpomatic);
 extern uint64_t thread_id ();
 extern int avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags);
+extern boost::filesystem::path home_directory ();
 
 /** @class Waker
  *  @brief A class which tries to keep the computer awake on various operating systems.
index 035118245fc150017b45dae8fa46b4ec2d988c28..4db00fb540de766e7a9c7ea289c7d3212b96ba70 100644 (file)
@@ -70,8 +70,8 @@ ContentView::update ()
        DeleteAllItems ();
        _content.clear ();
        optional<path> dir = Config::instance()->player_content_directory();
-       if (!dir) {
-               return;
+       if (!dir || !boost::filesystem::is_directory(*dir)) {
+               dir = home_directory ();
        }
 
        wxProgressDialog progress (_("DCP-o-matic"), _("Reading content directory"));