From df4b49e4be9c431d71e02309cacd6cb685548e4e Mon Sep 17 00:00:00 2001 From: Tsu Jan Date: Thu, 15 Aug 2024 22:59:17 +0330 Subject: [PATCH] Create libfm-qt dir if needed --- src/core/bookmarks.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/core/bookmarks.cpp b/src/core/bookmarks.cpp index 7ae9cc7b..28c8416d 100644 --- a/src/core/bookmarks.cpp +++ b/src/core/bookmarks.cpp @@ -164,11 +164,14 @@ void Bookmarks::save() { } idle_handler = false; // G_UNLOCK(bookmarks); - GError* err = nullptr; - if(!g_file_replace_contents(file_.gfile().get(), buf.c_str(), buf.length(), nullptr, - FALSE, G_FILE_CREATE_NONE, nullptr, nullptr, &err)) { - g_critical("%s", err->message); - g_error_free(err); + CStrPtr libfmDataDir{g_build_filename(g_get_user_data_dir(), "libfm-qt", nullptr)}; + if(g_mkdir_with_parents(libfmDataDir.get(), 0755) == 0) { + GError* err = nullptr; + if(!g_file_replace_contents(file_.gfile().get(), buf.c_str(), buf.length(), nullptr, + FALSE, G_FILE_CREATE_NONE, nullptr, nullptr, &err)) { + g_critical("%s", err->message); + g_error_free(err); + } } /* we changed bookmarks list, let inform who interested in that */ Q_EMIT changed();