class EE::System::FileAssociation¶
Overview¶
Registers a desktop application as a handler for filename extensions. More…
#include <fileassociation.hpp> class FileAssociation { public: // construction FileAssociation(FileAssociationApplication application); // methods std::vector<std::string> getRegisteredExtensions(const std::vector<std::string>& supportedExtensions) const; bool setRegisteredExtensions(const std::vector<std::string>& registeredExtensions, const std::vector<std::string>& supportedExtensions); bool setRegisteredExtensions(const std::vector<std::string>& registeredExtensions, const std::vector<std::string>& supportedExtensions, bool desktopEntryInstalled); bool isDesktopEntryInstalled() const; bool setDesktopEntryInstalled(bool installed); const std::string& getLastError() const; static bool isSupported(); static bool supportsDesktopEntries(); static std::string normalizeExtension(std::string_view extension); };
Detailed Documentation¶
Registers a desktop application as a handler for filename extensions.
Registrations are per-user. On Windows this adds the application to the Open With list, since current Windows versions do not allow applications to silently change the user’s default app. XDG desktops use a generated desktop entry and the shared MIME database. macOS uses Launch Services and therefore treats a selected extension as a request to make the application its editor.
Methods¶
std::vector<std::string> getRegisteredExtensions(const std::vector<std::string>& supportedExtensions) const
Returns the extensions from supportedExtensions currently registered for this app.
bool setRegisteredExtensions(const std::vector<std::string>& registeredExtensions, const std::vector<std::string>& supportedExtensions)
Makes registeredExtensions the registered subset of supportedExtensions.
bool setRegisteredExtensions(const std::vector<std::string>& registeredExtensions, const std::vector<std::string>& supportedExtensions, bool desktopEntryInstalled)
Makes registeredExtensions the registered subset of supportedExtensions and updates the desktop-entry visibility in the same operation. desktopEntryInstalled is ignored on platforms that do not support desktop entries.
static bool supportsDesktopEntries()
XDG platforms can additionally expose the generated desktop entry in application menus.
static std::string normalizeExtension(std::string_view extension)
Returns a lower-case extension without a leading dot, or an empty string if invalid.