Class ResourcesExtractor

Class Documentation

class appimage::utils::ResourcesExtractor

Allows to identify and extract the resources (files) required to integrate an AppImage into the desktop environment in an effective way.

Using the PayloadIterator::read method on symlinks is not reliable as it’s not supported on AppImages of type 1 (blame on libarchive). To overcome this limitation two iterations over the AppImage will be performed. One to resolve all the links entries and other to actually extract the resources.

Public Functions

explicit ResourcesExtractor(const core::AppImage &appImage)
std::vector<char> extract(const std::string &path) const

Read an entry into memory, if the entry is a link it will be resolved.

Throws

PayloadIteratorError – if the entry doesn’t exists

Returns

entry data

std::map<std::string, std::vector<char>> extract(const std::vector<std::string> &paths) const

Read each entry into memory, if the entry is a link it will be resolved.

Throws

PayloadIteratorError – if some entry doesn’t exists

Returns

entries data

void extractTo(const std::map<std::string, std::string> &targetsMap) const

Extract entries listed in ‘first’ member of the <targetsMap> iterator to the ‘second’ member of the <targetsMap> iterator. Will resolve links to regular files.

Parameters

targetsMap

std::string extractText(const std::string &path) const

Read an entry into a std::string, if the entry is a link it will be resolved. Should only be used in text files.

Throws

PayloadIteratorError – if the entry doesn’t exists

Returns

entry data

std::string getDesktopEntryPath() const
Returns

path to the main desktop entry of the AppImage

std::vector<std::string> getIconFilePaths(const std::string &iconName) const

Icons are expected to be located in “usr/share/icons/” according to the FreeDesktop Icon Theme Specification. This method look for entries in that path whose file name matches to the iconName

Parameters

iconName

Returns

list of the icon entries paths

std::vector<std::string> getMimeTypePackagesPaths() const

Mime-Type packages are xml files located usr/share/mime/packages according to the Shared MIME-info Database specification.

Parameters

iconName

Returns

Mime-Type packages entries paths