diff options
author | Ralf Donau <ruelle@volleyballschlaeger.de> | 2021-07-23 19:44:31 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-23 01:40:42 +0200 |
commit | 7d579b04c511e7333ddbf72da16bd347a3886854 (patch) | |
tree | 2fe140dbb47340ba150fbce0db711293e4c81e2f /Userland | |
parent | aacb1f0bf4c82569c7896930436f3bbd216fed67 (diff) | |
download | serenity-7d579b04c511e7333ddbf72da16bd347a3886854.zip |
TextEditor: Unveil the full path to the config file
Unveil ~/.config/TextEditor.ini instead of the whole config directory.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/TextEditor/MainWidget.cpp | 12 | ||||
-rw-r--r-- | Userland/Applications/TextEditor/MainWidget.h | 3 | ||||
-rw-r--r-- | Userland/Applications/TextEditor/main.cpp | 3 |
3 files changed, 15 insertions, 3 deletions
diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp index 3d734f3c1b..157daea08b 100644 --- a/Userland/Applications/TextEditor/MainWidget.cpp +++ b/Userland/Applications/TextEditor/MainWidget.cpp @@ -9,7 +9,6 @@ #include <AK/StringBuilder.h> #include <AK/URL.h> #include <Applications/TextEditor/TextEditorWindowGML.h> -#include <LibCore/ConfigFile.h> #include <LibCore/File.h> #include <LibCpp/SyntaxHighlighter.h> #include <LibDesktop/Launcher.h> @@ -47,7 +46,7 @@ MainWidget::MainWidget() { load_from_gml(text_editor_window_gml); - m_config = Core::ConfigFile::open_for_app("TextEditor", Core::ConfigFile::AllowWriting::Yes); + m_config = open_config_file(); m_toolbar = *find_descendant_of_type_named<GUI::Toolbar>("toolbar"); m_toolbar_container = *find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container"); @@ -345,6 +344,15 @@ MainWidget::~MainWidget() { } +static RefPtr<Core::ConfigFile> s_config; + +RefPtr<Core::ConfigFile> MainWidget::open_config_file() +{ + if (!s_config) + s_config = Core::ConfigFile::open_for_app("TextEditor", Core::ConfigFile::AllowWriting::Yes); + return s_config; +} + Web::OutOfProcessWebView& MainWidget::ensure_web_view() { if (!m_page_view) { diff --git a/Userland/Applications/TextEditor/MainWidget.h b/Userland/Applications/TextEditor/MainWidget.h index b6bbe1afc8..fad97abfaa 100644 --- a/Userland/Applications/TextEditor/MainWidget.h +++ b/Userland/Applications/TextEditor/MainWidget.h @@ -8,6 +8,7 @@ #include <AK/Function.h> #include <AK/LexicalPath.h> +#include <LibCore/ConfigFile.h> #include <LibFileSystemAccessClient/Client.h> #include <LibGUI/ActionGroup.h> #include <LibGUI/Application.h> @@ -42,6 +43,8 @@ public: void update_title(); void initialize_menubar(GUI::Window&); + static RefPtr<Core::ConfigFile> open_config_file(); + private: MainWidget(); void set_path(StringView const&); diff --git a/Userland/Applications/TextEditor/main.cpp b/Userland/Applications/TextEditor/main.cpp index f1e1a36049..34b1790f41 100644 --- a/Userland/Applications/TextEditor/main.cpp +++ b/Userland/Applications/TextEditor/main.cpp @@ -32,6 +32,7 @@ int main(int argc, char** argv) parser.parse(argc, argv); String file_to_edit_full_path; + auto config_filename = MainWidget::open_config_file()->filename(); if (file_to_edit) { FileArgument parsed_argument(file_to_edit); @@ -47,7 +48,7 @@ int main(int argc, char** argv) } } - if (unveil(Core::StandardPaths::config_directory().characters(), "rw") < 0) { + if (unveil(config_filename.characters(), "rwc") < 0) { perror("unveil"); return 1; } |