mirror of https://github.com/AxioDL/nod.git
API adjustments
This commit is contained in:
parent
8f2f4ea2e6
commit
ccb67d0d0e
|
@ -1,5 +1,5 @@
|
||||||
TEMPLATE = lib
|
TEMPLATE = app
|
||||||
CONFIG += staticlib c++11
|
CONFIG += console c++11
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
CONFIG -= qt
|
CONFIG -= qt
|
||||||
QT =
|
QT =
|
||||||
|
@ -15,10 +15,12 @@ HEADERS += \
|
||||||
include/DiscWii.hpp
|
include/DiscWii.hpp
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
lib/NODLib.cpp \
|
||||||
lib/DiscIOFILE.cpp \
|
lib/DiscIOFILE.cpp \
|
||||||
lib/DiscIOWBFS.cpp \
|
lib/DiscIOWBFS.cpp \
|
||||||
lib/FileIOFILE.cpp \
|
lib/FileIOFILE.cpp \
|
||||||
lib/FileIOMEM.cpp \
|
lib/FileIOMEM.cpp \
|
||||||
lib/DiscBase.cpp \
|
lib/DiscBase.cpp \
|
||||||
lib/DiscGCN.cpp \
|
lib/DiscGCN.cpp \
|
||||||
lib/DiscWii.cpp
|
lib/DiscWii.cpp \
|
||||||
|
main.cpp
|
||||||
|
|
|
@ -13,27 +13,48 @@ namespace NOD
|
||||||
class DiscBase
|
class DiscBase
|
||||||
{
|
{
|
||||||
IDiscIO& m_discIO;
|
IDiscIO& m_discIO;
|
||||||
protected:
|
|
||||||
struct Partition
|
public:
|
||||||
|
class IPartReadStream
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
virtual size_t read(void* buf, size_t length)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IPartWriteStream
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual size_t write(void* buf, size_t length)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
class Partition
|
||||||
|
{
|
||||||
|
public:
|
||||||
enum Kind
|
enum Kind
|
||||||
{
|
{
|
||||||
PART_DATA,
|
PART_DATA,
|
||||||
PART_UPDATE
|
PART_UPDATE
|
||||||
};
|
};
|
||||||
struct File
|
class File
|
||||||
{
|
{
|
||||||
|
const Partition& m_parent;
|
||||||
std::unique_ptr<IFileIO> m_hddFile;
|
std::unique_ptr<IFileIO> m_hddFile;
|
||||||
std::string m_discPath;
|
std::string m_discPath;
|
||||||
size_t m_discOffset;
|
size_t m_discOffset;
|
||||||
size_t m_discLength;
|
size_t m_discLength;
|
||||||
File(const std::string& discPath)
|
public:
|
||||||
: m_discPath(discPath) {}
|
File(const Partition& parent, const std::string& discPath)
|
||||||
|
: m_parent(parent), m_discPath(discPath) {}
|
||||||
|
std::unique_ptr<IPartReadStream> beginReadStream();
|
||||||
};
|
};
|
||||||
|
private:
|
||||||
std::list<File> files;
|
std::list<File> files;
|
||||||
Kind m_kind;
|
Kind m_kind;
|
||||||
|
public:
|
||||||
Partition(Kind kind)
|
Partition(Kind kind)
|
||||||
: m_kind(kind) {}
|
: m_kind(kind) {}
|
||||||
|
std::unique_ptr<IPartReadStream> beginReadStream(size_t offset);
|
||||||
};
|
};
|
||||||
std::list<Partition> partitions;
|
std::list<Partition> partitions;
|
||||||
Partition& addPartition(Partition::Kind kind);
|
Partition& addPartition(Partition::Kind kind);
|
||||||
|
@ -41,22 +62,6 @@ public:
|
||||||
DiscBase(IDiscIO& dio);
|
DiscBase(IDiscIO& dio);
|
||||||
virtual bool sync()=0;
|
virtual bool sync()=0;
|
||||||
|
|
||||||
class IPartReadStream
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual size_t read(void* buf, size_t length)=0;
|
|
||||||
};
|
|
||||||
virtual std::unique_ptr<IPartReadStream> beginDataReadStream()=0;
|
|
||||||
virtual std::unique_ptr<IPartReadStream> beginUpdateReadStream()=0;
|
|
||||||
|
|
||||||
class IPartWriteStream
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual size_t write(void* buf, size_t length)=0;
|
|
||||||
};
|
|
||||||
virtual std::unique_ptr<IPartWriteStream> beginDataWriteStream()=0;
|
|
||||||
virtual std::unique_ptr<IPartWriteStream> beginUpdateWriteStream()=0;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,14 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual size_t read(void* buf, size_t length)=0;
|
virtual size_t read(void* buf, size_t length)=0;
|
||||||
};
|
};
|
||||||
virtual std::unique_ptr<IReadStream> beginReadStream(size_t offset);
|
virtual std::unique_ptr<IReadStream> beginReadStream(size_t offset)=0;
|
||||||
|
|
||||||
class IWriteStream
|
class IWriteStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual size_t write(void* buf, size_t length)=0;
|
virtual size_t write(void* buf, size_t length)=0;
|
||||||
};
|
};
|
||||||
virtual std::unique_ptr<IWriteStream> beginWriteStream(size_t offset);
|
virtual std::unique_ptr<IWriteStream> beginWriteStream(size_t offset)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
namespace NOD
|
namespace NOD
|
||||||
{
|
{
|
||||||
|
|
||||||
std::unique_ptr<IDiscIO> NewDiscIOFILE(const char* path);
|
std::unique_ptr<DiscBase> OpenDiscFromImage(const char* path);
|
||||||
std::unique_ptr<IDiscIO> NewDiscIOWBFS(const char* path);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "DiscBase.hpp"
|
||||||
|
|
||||||
|
namespace NOD
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
14
main.cpp
14
main.cpp
|
@ -1,10 +1,14 @@
|
||||||
#include <iostream>
|
#include "NODLib.hpp"
|
||||||
|
|
||||||
using namespace std;
|
int main(int argc, char* argv[])
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
{
|
||||||
cout << "Hello World!" << endl;
|
if (argc < 2)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
std::unique_ptr<NOD::DiscBase> disc = NOD::OpenDiscFromImage(argv[1]);
|
||||||
|
if (!disc)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue