diff --git a/NODLib.pro b/NODLib.pro index 30e77d4..b19a736 100644 --- a/NODLib.pro +++ b/NODLib.pro @@ -1,5 +1,5 @@ -TEMPLATE = lib -CONFIG += staticlib c++11 +TEMPLATE = app +CONFIG += console c++11 CONFIG -= app_bundle CONFIG -= qt QT = @@ -15,10 +15,12 @@ HEADERS += \ include/DiscWii.hpp SOURCES += \ + lib/NODLib.cpp \ lib/DiscIOFILE.cpp \ lib/DiscIOWBFS.cpp \ lib/FileIOFILE.cpp \ lib/FileIOMEM.cpp \ lib/DiscBase.cpp \ lib/DiscGCN.cpp \ - lib/DiscWii.cpp + lib/DiscWii.cpp \ + main.cpp diff --git a/include/DiscBase.hpp b/include/DiscBase.hpp index 633c1b3..31fe153 100644 --- a/include/DiscBase.hpp +++ b/include/DiscBase.hpp @@ -13,27 +13,48 @@ namespace NOD class DiscBase { 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 { PART_DATA, PART_UPDATE }; - struct File + class File { + const Partition& m_parent; std::unique_ptr m_hddFile; std::string m_discPath; size_t m_discOffset; size_t m_discLength; - File(const std::string& discPath) - : m_discPath(discPath) {} + public: + File(const Partition& parent, const std::string& discPath) + : m_parent(parent), m_discPath(discPath) {} + std::unique_ptr beginReadStream(); }; + private: std::list files; Kind m_kind; + public: Partition(Kind kind) : m_kind(kind) {} + std::unique_ptr beginReadStream(size_t offset); }; std::list partitions; Partition& addPartition(Partition::Kind kind); @@ -41,22 +62,6 @@ public: DiscBase(IDiscIO& dio); virtual bool sync()=0; - class IPartReadStream - { - public: - virtual size_t read(void* buf, size_t length)=0; - }; - virtual std::unique_ptr beginDataReadStream()=0; - virtual std::unique_ptr beginUpdateReadStream()=0; - - class IPartWriteStream - { - public: - virtual size_t write(void* buf, size_t length)=0; - }; - virtual std::unique_ptr beginDataWriteStream()=0; - virtual std::unique_ptr beginUpdateWriteStream()=0; - }; } diff --git a/include/IDiscIO.hpp b/include/IDiscIO.hpp index 5ad04d4..1454f8d 100644 --- a/include/IDiscIO.hpp +++ b/include/IDiscIO.hpp @@ -17,14 +17,14 @@ public: public: virtual size_t read(void* buf, size_t length)=0; }; - virtual std::unique_ptr beginReadStream(size_t offset); + virtual std::unique_ptr beginReadStream(size_t offset)=0; class IWriteStream { public: virtual size_t write(void* buf, size_t length)=0; }; - virtual std::unique_ptr beginWriteStream(size_t offset); + virtual std::unique_ptr beginWriteStream(size_t offset)=0; }; } diff --git a/include/NODLib.hpp b/include/NODLib.hpp index 8ce4b32..69170c4 100644 --- a/include/NODLib.hpp +++ b/include/NODLib.hpp @@ -9,8 +9,7 @@ namespace NOD { -std::unique_ptr NewDiscIOFILE(const char* path); -std::unique_ptr NewDiscIOWBFS(const char* path); +std::unique_ptr OpenDiscFromImage(const char* path); } diff --git a/lib/DiscBase.cpp b/lib/DiscBase.cpp index e69de29..a9e52ee 100644 --- a/lib/DiscBase.cpp +++ b/lib/DiscBase.cpp @@ -0,0 +1,6 @@ +#include "DiscBase.hpp" + +namespace NOD +{ + +} diff --git a/main.cpp b/main.cpp index 5f5419b..48da543 100644 --- a/main.cpp +++ b/main.cpp @@ -1,10 +1,14 @@ -#include +#include "NODLib.hpp" -using namespace std; - -int main() +int main(int argc, char* argv[]) { - cout << "Hello World!" << endl; + if (argc < 2) + return -1; + + std::unique_ptr disc = NOD::OpenDiscFromImage(argv[1]); + if (!disc) + return -1; + return 0; }