From 0d6f1b0837e9ad770b0c9b650d5e3f5f474bee79 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Fri, 11 Dec 2020 02:53:20 +0100 Subject: [PATCH] vst: workaround in case the documents folder is missing --- vst/NativeHelpers.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vst/NativeHelpers.cpp b/vst/NativeHelpers.cpp index 2015a194..3ada4d93 100644 --- a/vst/NativeHelpers.cpp +++ b/vst/NativeHelpers.cpp @@ -6,6 +6,7 @@ #include "NativeHelpers.h" #include +#include #if defined(_WIN32) #include @@ -30,9 +31,14 @@ const fs::path& getUserDocumentsDirectory() { static const fs::path directory = []() -> fs::path { const gchar* path = g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS); - if (!path) + if (path) + return fs::path(path); + else { + const char* home = getenv("HOME"); + if (home && home[0] == '/') + return fs::path(home) / "Documents"; throw std::runtime_error("Cannot get the document directory."); - return fs::path(path); + } }(); return directory; }