class EE::System::Pack

Overview

Base class for all packing classes. More…

#include <pack.hpp>

class Pack: protected EE::System::Mutex {
public:
    // construction

    virtual ~Pack();

    // methods

    virtual bool create(const std::string& path) = 0;
    virtual bool open(const std::string& path) = 0;
    virtual bool close() = 0;
    virtual bool addFile(const std::string& path, const std::string& inpack) = 0;
    virtual bool addFile(std::vector<Uint8>& data, const std::string& inpack) = 0;
    virtual bool addFile(const Uint8* data, const Uint32& dataSize, const std::string& inpack) = 0;
    virtual bool addFiles(std::map<std::string, std::string> paths) = 0;
    virtual bool eraseFile(const std::string& path) = 0;
    virtual bool eraseFiles(const std::vector<std::string>& paths) = 0;
    virtual bool extractFile(const std::string& path, const std::string& dest) = 0;
    virtual bool extractFileToMemory(const std::string& path, std::vector<Uint8>& data) = 0;
    virtual bool extractFileToMemory(const std::string& path, ScopedBuffer& data) = 0;
    virtual Int32 exists(const std::string& path) = 0;
    virtual Int8 checkPack() = 0;
    virtual std::vector<std::string> getFileList() = 0;
    virtual bool isOpen() const;
    virtual std::string getPackPath() = 0;
    virtual IOStream* getFileStream(const std::string& path) = 0;
};

Inherited Members

public:
    // methods

    void lock();
    void unlock();
    int tryLock();

Detailed Documentation

Base class for all packing classes.

Methods

virtual bool create(const std::string& path) = 0

Creates a new pack file

virtual bool open(const std::string& path) = 0

Open a pack file

virtual bool close() = 0

Close the pack file

virtual bool addFile(const std::string& path, const std::string& inpack) = 0

Add a file to the pack file

Parameters:

path

Path to the file in the disk

inpack

Path that will have the file inside the pak

Returns:

True if success

virtual bool addFile(std::vector<Uint8>& data, const std::string& inpack) = 0

Add a new file from memory

virtual bool addFile(const Uint8* data, const Uint32& dataSize, const std::string& inpack) = 0

Add a new file from memory

virtual bool addFiles(std::map<std::string, std::string> paths) = 0

Add a map of files to the pack file ( myMap[ myFilepath ] = myInPackFilepath )

virtual bool eraseFile(const std::string& path) = 0

Erase a file from the pack file. ( This will create a new pack file without that file, so, can be slow )

virtual bool eraseFiles(const std::vector<std::string>& paths) = 0

Erase all passed files from the pack file. ( This will create a new pack file without that file, so, can be slow )

virtual bool extractFile(const std::string& path, const std::string& dest) = 0

Extract a file from the pack file

virtual bool extractFileToMemory(const std::string& path, std::vector<Uint8>& data) = 0

Extract a file to memory from the pack file

virtual bool extractFileToMemory(const std::string& path, ScopedBuffer& data) = 0

Extract a file to memory from the pack file

virtual Int32 exists(const std::string& path) = 0

Check if a file exists in the pack file and return the number of the file, otherwise return -1.

virtual Int8 checkPack() = 0

Check the integrity of the pack file.

If return 0 integrity OK. -1 wrong indentifier. -2 wrong header.

virtual std::vector<std::string> getFileList() = 0

Returns:

a vector with all the files inside the pack file

virtual bool isOpen() const

Returns:

If the pack file is open

virtual std::string getPackPath() = 0

Returns:

The file path of the opened package

virtual IOStream* getFileStream(const std::string& path) = 0

Open a file stream for reading