Removed exceptions

This commit is contained in:
Jack Andersen 2015-07-25 16:44:44 -10:00
parent 9e7e0979bd
commit 7fafe3ce0c
8 changed files with 36 additions and 36 deletions

@ -1 +1 @@
Subproject commit 085920205b71a0a5a9bf710de5794cc136051b2d
Subproject commit c61ff288b90a6b4c833d01f62196eb0534bf2860

View File

@ -52,7 +52,8 @@ int main(int argc, char* argv[])
if (!dataPart)
return -1;
dataPart->extractToDirectory(outDir, force);
if (!dataPart->extractToDirectory(outDir, force))
return -1;
}
else if (!strcasecmp(argv[1], _S("make")))
{

View File

@ -107,7 +107,7 @@ public:
{
if (m_kind != NODE_FILE)
{
throw std::runtime_error("unable to stream a non-file");
LogModule.report(LogVisor::Error, "unable to stream a non-file %s", m_name.c_str());
return std::unique_ptr<IPartReadStream>();
}
return m_parent.beginReadStream(m_discOffset + offset);
@ -116,7 +116,7 @@ public:
{
if (m_kind != NODE_FILE)
{
throw std::runtime_error("unable to buffer a non-file");
LogModule.report(LogVisor::Error, "unable to buffer a non-file %s", m_name.c_str());
return std::unique_ptr<uint8_t[]>();
}
uint8_t* buf = new uint8_t[m_discLength];
@ -163,7 +163,7 @@ public:
return end();
}
void extractToDirectory(const SystemString& basePath, bool force=false) const;
bool extractToDirectory(const SystemString& basePath, bool force=false) const;
};
protected:
uint64_t m_dolOff;
@ -194,7 +194,7 @@ public:
{return beginReadStream(0x2440 + offset);}
inline const Node& getFSTRoot() const {return m_nodes[0];}
inline Node& getFSTRoot() {return m_nodes[0];}
void extractToDirectory(const SystemString& path, bool force=false);
bool extractToDirectory(const SystemString& path, bool force=false);
inline uint64_t getDOLSize() const {return m_dolSz;}
inline std::unique_ptr<uint8_t[]> getDOLBuf() const

View File

@ -57,7 +57,7 @@ void DiscBase::IPartition::parseDOL(IPartReadStream& s)
m_dolSz = dolSize;
}
void DiscBase::IPartition::Node::extractToDirectory(const SystemString& basePath, bool force) const
bool DiscBase::IPartition::Node::extractToDirectory(const SystemString& basePath, bool force) const
{
SystemStringView nameView(getName());
SystemString path = basePath + _S("/") + nameView.sys_str();
@ -65,11 +65,12 @@ void DiscBase::IPartition::Node::extractToDirectory(const SystemString& basePath
{
if (Mkdir(path.c_str(), 0755) && errno != EEXIST)
{
SystemUTF8View pathView(path);
throw std::runtime_error("unable to mkdir '" + pathView.utf8_str() + "'");
LogModule.report(LogVisor::Error, _S("unable to mkdir '%s'"), path.c_str());
return false;
}
for (Node& subnode : *this)
subnode.extractToDirectory(path, force);
if (!subnode.extractToDirectory(path, force))
return false;
}
else if (m_kind == NODE_FILE)
{
@ -81,15 +82,16 @@ void DiscBase::IPartition::Node::extractToDirectory(const SystemString& basePath
ws->copyFromDisc(*rs.get(), m_discLength);
}
}
return true;
}
void DiscBase::IPartition::extractToDirectory(const SystemString& path, bool force)
bool DiscBase::IPartition::extractToDirectory(const SystemString& path, bool force)
{
Sstat theStat;
if (Mkdir(path.c_str(), 0755) && errno != EEXIST)
{
SystemUTF8View pathView(path);
throw std::runtime_error("unable to mkdir '" + pathView.utf8_str() + "'");
LogModule.report(LogVisor::Error, _S("unable to mkdir '%s'"), path.c_str());
return false;
}
/* Extract Apploader */
@ -109,7 +111,7 @@ void DiscBase::IPartition::extractToDirectory(const SystemString& path, bool for
}
/* Extract Filesystem */
m_nodes[0].extractToDirectory(path, force);
return m_nodes[0].extractToDirectory(path, force);
}
}

View File

@ -1,5 +1,4 @@
#include <stdio.h>
#include <stdexcept>
#include "NOD/Util.hpp"
#include "NOD/IDiscIO.hpp"

View File

@ -1,5 +1,4 @@
#include <stdio.h>
#include <stdexcept>
#include "NOD/Util.hpp"
#include "NOD/IDiscIO.hpp"

View File

@ -388,7 +388,7 @@ DiscWii::DiscWii(std::unique_ptr<IDiscIO>&& dio)
else if (part.partType == PartInfo::Part::PART_CHANNEL)
kind = IPartition::PART_CHANNEL;
else
throw std::runtime_error("Invalid partition type");
LogModule.report(LogVisor::FatalError, "invalid partition type %s", part.partType);
m_partitions.emplace_back(new PartitionWii(*this, kind, part.partDataOff << 2));
}
}

View File

@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdexcept>
#include "NOD/Util.hpp"
#include "NOD/IFileIO.hpp"
@ -50,13 +49,7 @@ public:
fp = fopen(path.c_str(), "wb");
#endif
if (!fp)
{
#if NOD_UCS2
throw std::runtime_error("Unable to open '" + WideToUTF8(path) + "' for writing");
#else
throw std::runtime_error("Unable to open '" + path + "' for writing");
#endif
}
LogModule.report(LogVisor::Error, _S("unable to open '%s' for writing"), path.c_str());
}
~WriteStream() {fclose(fp);}
uint64_t write(void* buf, uint64_t length)
@ -69,9 +62,15 @@ public:
uint64_t thisSz = MIN(0x7c00, length);
uint64_t readSz = discio.read(buf, thisSz);
if (thisSz != readSz)
throw std::runtime_error("unable to read enough from disc");
{
LogModule.report(LogVisor::Error, "unable to read enough from disc");
return read;
}
if (fwrite(buf, 1, readSz, fp) != readSz)
throw std::runtime_error("unable to write in file");
{
LogModule.report(LogVisor::Error, "unable to write in file");
return read;
}
length -= thisSz;
read += thisSz;
}
@ -93,13 +92,7 @@ public:
fp = fopen(path.c_str(), "rb");
#endif
if (!fp)
{
#if NOD_UCS2
throw std::runtime_error("Unable to open '" + WideToUTF8(path) + "' for reading");
#else
throw std::runtime_error("Unable to open '" + path + "' for reading");
#endif
}
LogModule.report(LogVisor::Error, _S("unable to open '%s' for reading"), path.c_str());
}
~ReadStream() {fclose(fp);}
uint64_t read(void* buf, uint64_t length)
@ -111,9 +104,15 @@ public:
{
uint64_t thisSz = MIN(0x7c00, length);
if (fread(buf, 1, thisSz, fp) != thisSz)
throw std::runtime_error("unable to read enough from file");
{
LogModule.report(LogVisor::Error, "unable to read enough from file");
return written;
}
if (discio.write(buf, thisSz) != thisSz)
throw std::runtime_error("unable to write enough to disc");
{
LogModule.report(LogVisor::Error, "unable to write enough to disc");
return written;
}
length -= thisSz;
written += thisSz;
}