Class PayloadIterator
Defined in File PayloadIterator.h
Inheritance Relationships
Base Type
public std::iterator< std::input_iterator_tag, std::string >
Class Documentation
-
class appimage::core::PayloadIterator : public std::iterator<std::input_iterator_tag, std::string>
A FilesIterator object provides a READONLY, SINGLE WAY, ONE PASS iterator over the files contained in the AppImage pointed by <path>. Abstracts the users from the AppImage file payload format.
READONLY: files inside the AppImage cannot be modified. SINGLE WAY: can’t go backwards only forward. ONE PASS: A new instance is required to re-traverse the AppImage or re-read an entry.
Public Functions
-
explicit PayloadIterator(const AppImage &appImage)
Create a FilesIterator for <appImage>
- Parameters
appImage –
- Throws
AppImageReadError – in case of error
-
PayloadIterator(PayloadIterator &other) = delete
-
PayloadIterator &operator=(PayloadIterator &other) = delete
-
PayloadIterator(PayloadIterator &&other) noexcept
-
PayloadIterator &operator=(PayloadIterator &&other) noexcept
-
PayloadEntryType type()
- Returns
the type of the current file.
-
std::string path()
- Returns
file path pointed by the iterator
-
std::string linkTarget()
- Returns
file link path if it’s a LINK type file. Otherwise returns an empty string.
-
void extractTo(const std::string &target)
Extracts the file to the <target> path. Supports raw files, symlinks and directories. Parent target dir is created if not exists.
IMPORTANT:
Due to implementation restrictions you can call read() or extractTo() in a given entry only once. Additional call will throw a PayloadIteratorError.
- Throws
AppImageError – if called on a PayloadEntry of UNKNOWN Type
- Parameters
target –
-
std::istream &read()
Read file content. Symbolic links will be resolved.
IMPORTANT:
The returned istream becomes invalid after next is called, don’t try to “reuse” it.
Due to implementation restrictions you can call read() or extractTo() a given entry only once. Additional call will throw a PayloadIteratorError.
- Throws
AppImageError – if called on a PayloadEntry of UNKNOWN Type
- Returns
file content stream
-
bool operator==(const PayloadIterator &other) const
Compare this iterator to <other>.
- Parameters
other –
- Returns
true of both are equal, false otherwise
-
bool operator!=(const PayloadIterator &other) const
Compare this iterator to <other>.
- Parameters
other –
- Returns
true if are different, false otherwise
-
std::string operator*()
- Returns
file path pointed by the iterator
-
PayloadIterator &operator++()
Move iterator to the next file.
- Returns
current file_iterator
-
PayloadIterator begin()
Represents the begin of the iterator. Will always point to the current iterator.
- Returns
current file_iterator
-
PayloadIterator end()
Represent the end of the iterator. Will always point to an invalid iterator.
- Returns
invalid file_iterator
-
explicit PayloadIterator(const AppImage &appImage)