From 1b1137dac3167de7e4bb23d86a4f3505ad880675 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 14 Dec 2018 20:35:58 +0000 Subject: [PATCH] swaroop: fall back to home directory if the content directory is not present. --- src/lib/cross.cc | 11 +++++++++++ src/lib/cross.h | 1 + src/wx/content_view.cc | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lib/cross.cc b/src/lib/cross.cc index 61b150a3b..b9b215303 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -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 +} diff --git a/src/lib/cross.h b/src/lib/cross.h index cd0372338..ee5e7919a 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -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. diff --git a/src/wx/content_view.cc b/src/wx/content_view.cc index 035118245..4db00fb54 100644 --- a/src/wx/content_view.cc +++ b/src/wx/content_view.cc @@ -70,8 +70,8 @@ ContentView::update () DeleteAllItems (); _content.clear (); optional 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")); -- 2.30.2