diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-09-27 15:26:05 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-09-27 15:26:05 +0100 |
| commit | 1f1661f36ffd7a5662847f0642c7a7ebdcadc0f0 (patch) | |
| tree | e08493b2dd48d4f687ab6f16e129782147590640 /src/lib | |
| parent | 464801a7b386f93be65cdfc60c3807cb5365467e (diff) | |
Disable preferences menu if the config can't be written.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/config.cc | 12 | ||||
| -rw-r--r-- | src/lib/config.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index d7fd74449..e1d5b958d 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -1201,3 +1201,15 @@ Config::copy_and_link (boost::filesystem::path new_file) const boost::filesystem::copy_file (config_file(), new_file, boost::filesystem::copy_option::overwrite_if_exists); link (new_file); } + +bool +Config::have_write_permission () const +{ + FILE* f = fopen_boost (config_file(), "r+"); + if (!f) { + return false; + } + + fclose (f); + return true; +} diff --git a/src/lib/config.h b/src/lib/config.h index bcc46f8fa..80bb48d32 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -1002,6 +1002,7 @@ public: void write_cinemas () const; void link (boost::filesystem::path new_file) const; void copy_and_link (boost::filesystem::path new_file) const; + bool have_write_permission () const; void save_template (boost::shared_ptr<const Film> film, std::string name) const; bool existing_template (std::string name) const; |
