1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
#pragma once
// system
#include <memory>
#include <string>
#include <vector>
// local
#include <appimage/core/AppImageFormat.h>
#include <appimage/core/PayloadIterator.h>
#include <appimage/core/exceptions.h>
namespace appimage {
namespace core {
/**
* An object of class <appimage> represents an existent AppImage file. Provides readonly methods to
* access the AppImage information and contained files.
*/
class AppImage {
public:
/**
* Open the AppImage at <path>.
* @param path
* @throw AppImageError if something goes wrong
*/
explicit AppImage(const std::string& path);
/**
* Creates an AppImage instance from <other> AppImage
* @param other
*/
AppImage(const AppImage& other);
/**
* Copy the <other> instance data into the current one.
* @param other
* @return
*/
AppImage& operator=(const AppImage& other);
/**
* Default destructor.
*
* Required by `std::shared_ptr` to work properly.
*/
virtual ~AppImage();
/**
* @return AppImage file path
*/
const std::string& getPath() const;
/**
* Inspect the magic bytes of the file to guess the AppImage <FORMAT>
* @return AppImage <FORMAT>
*/
AppImageFormat getFormat() const;
/**
* Inspect the magic bytes of the file to guess the AppImage <FORMAT>
* @return AppImage <FORMAT>
*/
static AppImageFormat getFormat(const std::string& path);
/**
* Calculate the offset in the AppImage file where is located the payload file system.
*
* @return offset where the payload filesystem is located.
*/
off_t getPayloadOffset() const;
/**
* Provides a one way iterator to traverse and access the files contained inside the AppImage.
* @return a files_iterator instance
* @throw AppImageError if something goes wrong
*/
PayloadIterator files() const;
/**
* Compare this to <rhs>
* @param rhs
* @return true if both are equal, false otherwise
*/
bool operator==(const AppImage& rhs) const;
/**
* Compare this to <rhs>
* @param rhs
* @return true if they are different, false otherwise
*/
bool operator!=(const AppImage& rhs) const;
private:
class Private;
std::shared_ptr<Private> d; // opaque pointer
};
}
}
|