1
0
mirror of synced 2024-11-24 15:50:16 +01:00

feat: Do not save memory providers as recent entries (#1259)

This commit is contained in:
iTrooz 2023-08-25 15:35:15 +02:00 committed by GitHub
parent a1dc979217
commit 175e66a60e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -61,6 +61,12 @@ namespace hex::prv {
*/
[[nodiscard]] virtual bool isDumpable() const;
/**
* @brief Controls whether this provider can be saved as a recent entry
* Tipitcally used for providers that do not retain data, e.g. the memory provider
*/
[[nodiscard]] virtual bool isSavableAsRecent() const { return true; }
/**
* @brief Read data from this provider, applying overlays and patches
* @param offset offset to start reading the data

View File

@ -15,6 +15,7 @@ namespace hex::plugin::builtin {
[[nodiscard]] bool isWritable() const override { return !this->m_readOnly; }
[[nodiscard]] bool isResizable() const override { return !this->m_readOnly; }
[[nodiscard]] bool isSavable() const override { return this->m_name.empty(); }
[[nodiscard]] bool isSavableAsRecent() const override { return false; }
[[nodiscard]] bool open() override;
void close() override { }

View File

@ -33,6 +33,9 @@ namespace hex::plugin::builtin::recent {
// do not save to recents if the provider is part of a project
if (ProjectFile::hasPath()) return;
// do not save to recents if the provider doesnt want it
if (!provider->isSavableAsRecent()) return;
// The recent provider is saved to every "recent" directory
for (const auto &recentPath : fs::getDefaultPaths(fs::ImHexPath::Recent)) {
wolv::io::File recentFile(recentPath / fileName, wolv::io::File::Mode::Create);