2017-07-18 14:17:32 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <fnd/types.h>
|
2018-10-14 05:45:09 +00:00
|
|
|
#include <fnd/IByteModel.h>
|
2017-07-18 14:17:32 +00:00
|
|
|
#include <fnd/List.h>
|
2018-10-22 13:30:49 +00:00
|
|
|
#include <nn/hac/define/pfs.h>
|
2017-07-18 14:17:32 +00:00
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
namespace nn
|
|
|
|
{
|
|
|
|
namespace hac
|
2017-07-18 14:17:32 +00:00
|
|
|
{
|
2018-10-27 05:43:57 +00:00
|
|
|
class PartitionFsHeader :
|
2018-10-14 05:45:09 +00:00
|
|
|
public fnd::IByteModel
|
2017-07-18 14:17:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-04-07 08:03:01 +00:00
|
|
|
enum FsType
|
|
|
|
{
|
|
|
|
TYPE_PFS0,
|
|
|
|
TYPE_HFS0
|
|
|
|
};
|
|
|
|
|
2017-07-18 14:17:32 +00:00
|
|
|
struct sFile
|
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
size_t offset;
|
|
|
|
size_t size;
|
2018-04-07 08:03:01 +00:00
|
|
|
size_t hash_protected_size;
|
2018-08-07 08:35:03 +00:00
|
|
|
fnd::sha::sSha256Hash hash;
|
2017-07-18 14:17:32 +00:00
|
|
|
|
|
|
|
sFile& operator=(const sFile& other)
|
|
|
|
{
|
|
|
|
name = other.name;
|
|
|
|
offset = other.offset;
|
|
|
|
size = other.size;
|
2018-04-07 08:03:01 +00:00
|
|
|
hash_protected_size = other.hash_protected_size;
|
|
|
|
hash = other.hash;
|
2017-07-18 14:17:32 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const sFile& other) const
|
|
|
|
{
|
|
|
|
return (name == other.name) \
|
|
|
|
&& (offset == other.offset) \
|
2018-04-07 08:03:01 +00:00
|
|
|
&& (size == other.size) \
|
|
|
|
&& (hash_protected_size == other.hash_protected_size) \
|
|
|
|
&& (hash == other.hash);
|
2017-07-18 14:17:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const sFile& other) const
|
|
|
|
{
|
|
|
|
return !operator==(other);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const std::string& other) const
|
|
|
|
{
|
|
|
|
return (name == other);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const std::string& other) const
|
|
|
|
{
|
|
|
|
return !operator==(other);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-10-27 05:43:57 +00:00
|
|
|
PartitionFsHeader();
|
|
|
|
PartitionFsHeader(const PartitionFsHeader& other);
|
2017-07-18 14:17:32 +00:00
|
|
|
|
2018-10-27 05:43:57 +00:00
|
|
|
void operator=(const PartitionFsHeader& other);
|
|
|
|
bool operator==(const PartitionFsHeader& other) const;
|
|
|
|
bool operator!=(const PartitionFsHeader& other) const;
|
2017-07-18 14:17:32 +00:00
|
|
|
|
2018-10-18 12:48:16 +00:00
|
|
|
// IByteModel
|
2018-06-24 08:18:54 +00:00
|
|
|
void toBytes();
|
|
|
|
void fromBytes(const byte_t* bytes, size_t len);
|
|
|
|
const fnd::Vec<byte_t>& getBytes() const;
|
2017-07-18 14:17:32 +00:00
|
|
|
|
|
|
|
// variables
|
|
|
|
void clear();
|
|
|
|
|
2018-04-07 08:03:01 +00:00
|
|
|
FsType getFsType() const;
|
|
|
|
void setFsType(FsType type);
|
2017-07-18 14:17:32 +00:00
|
|
|
const fnd::List<sFile>& getFileList() const;
|
|
|
|
void addFile(const std::string& name, size_t size);
|
2018-08-07 08:35:03 +00:00
|
|
|
void addFile(const std::string& name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash);
|
2017-07-18 14:17:32 +00:00
|
|
|
|
|
|
|
private:
|
2018-10-27 05:43:57 +00:00
|
|
|
const std::string kModuleName = "PARTITIONFS_HEADER";
|
2017-07-18 14:17:32 +00:00
|
|
|
|
|
|
|
// binary blob
|
2018-06-24 08:18:54 +00:00
|
|
|
fnd::Vec<byte_t> mRawBinary;
|
2017-07-18 14:17:32 +00:00
|
|
|
|
|
|
|
// variables
|
2018-04-07 08:03:01 +00:00
|
|
|
FsType mFsType;
|
2017-07-18 14:17:32 +00:00
|
|
|
fnd::List<sFile> mFileList;
|
|
|
|
|
2018-04-07 08:03:01 +00:00
|
|
|
size_t getFileEntrySize(FsType fs_type);
|
2017-07-18 14:17:32 +00:00
|
|
|
void calculateOffsets(size_t data_offset);
|
|
|
|
};
|
|
|
|
}
|
2018-08-07 07:17:51 +00:00
|
|
|
}
|