nstool/lib/nx/FacBinary.h

85 lines
2.1 KiB
C
Raw Normal View History

#pragma once
#include <string>
#include <fnd/memory_blob.h>
#include <fnd/List.h>
#include <nx/ISerialiseableBinary.h>
#include <nx/FacHeader.h>
2017-07-06 11:17:21 +00:00
namespace nx
{
2017-07-06 11:17:21 +00:00
class FacBinary :
public ISerialiseableBinary
{
2017-07-06 11:17:21 +00:00
public:
enum FsAccessFlag
{
FSA_APPLICATION_INFO = BIT(0),
FSA_BOOT_MODE_CONTROL = BIT(1),
FSA_CALIBRATION = BIT(2),
FSA_SYSTEM_SAVE_DATA = BIT(3),
FSA_GAME_CARD = BIT(4),
FSA_SAVE_DATA_BACKUP = BIT(5),
FSA_SAVE_DATA_MANAGEMENT = BIT(6),
FSA_BIS_ALL_RAW = BIT(7),
FSA_GAME_CARD_RAW = BIT(8),
FSA_GAME_CARD_PRIVATE = BIT(9),
FSA_SET_TIME = BIT(10),
FSA_CONTENT_MANAGER = BIT(11),
FSA_IMAGE_MANAGER = BIT(12),
FSA_CREATE_SAVE_DATA = BIT(13),
FSA_SYSTEM_SAVE_DATA_MANAGEMENT = BIT(14),
FSA_BIS_FILE_SYSTEM = BIT(15),
FSA_SYSTEM_UPDATE = BIT(16),
FSA_SAVE_DATA_META = BIT(17),
FSA_DEVICE_SAVE_CONTROL = BIT(19),
FSA_SETTINGS_CONTROL = BIT(20),
FSA_DEBUG = BIT(62),
FSA_FULL_PERMISSION = BIT(63),
};
2017-07-06 11:17:21 +00:00
FacBinary();
FacBinary(const FacBinary& other);
FacBinary(const u8* bytes, size_t len);
2017-07-06 11:17:21 +00:00
bool operator==(const FacBinary& other) const;
bool operator!=(const FacBinary& other) const;
void operator=(const FacBinary& other);
2017-07-06 11:17:21 +00:00
// to be used after export
const u8* getBytes() const;
size_t getSize() const;
2017-07-06 11:17:21 +00:00
// export/import binary
void exportBinary();
void importBinary(const u8* bytes);
void importBinary(const u8* bytes, size_t len);
2017-07-06 11:17:21 +00:00
// variables
bool isPermissionSet(FsAccessFlag flag) const;
void addPermission(FsAccessFlag flag);
void removePermission(FsAccessFlag flag);
2017-07-06 11:17:21 +00:00
const fnd::List<u32>& getContentOwnerIds() const;
void addContentOwnerId(u32 id);
2017-07-06 11:17:21 +00:00
const fnd::List<u32>& getSaveDataOwnerIds() const;
void addSaveDataOwnerId(u32 id);
private:
const std::string kModuleName = "FAC_BINARY";
2017-07-06 11:17:21 +00:00
// raw binary
fnd::MemoryBlob mBinaryBlob;
2017-07-06 11:17:21 +00:00
// variables
FacHeader mHeader;
u64 mFsaRights;
fnd::List<u32> mContentOwnerIds;
fnd::List<u32> mSaveDataOwnerIds;
2017-07-06 11:17:21 +00:00
void clearVariables();
bool isEqual(const FacBinary& other) const;
void copyFrom(const FacBinary& other);
};
}