mirror of https://github.com/libAthena/athena.git
* Fix bug in BinaryReader where it wasn't correctly reading in all the data
This commit is contained in:
parent
8adb9c0e98
commit
1e2065b352
|
@ -139,7 +139,7 @@ public:
|
||||||
*/
|
*/
|
||||||
std::string readUnicode();
|
std::string readUnicode();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
/*! \brief Overload of isOpenForWriting in Stream
|
/*! \brief Overload of isOpenForWriting in Stream
|
||||||
*
|
*
|
||||||
* \return false
|
* \return false
|
||||||
|
|
|
@ -30,14 +30,15 @@ public:
|
||||||
/*! \brief The constructor for an Exception
|
/*! \brief The constructor for an Exception
|
||||||
* \param message The error message to throw
|
* \param message The error message to throw
|
||||||
*/
|
*/
|
||||||
Exception(const std::string& message) :
|
inline Exception(const std::string& message) :
|
||||||
m_message(message)
|
m_message(message)
|
||||||
{};
|
{
|
||||||
|
};
|
||||||
|
|
||||||
/*! \brief Returns the Error message of the exception
|
/*! \brief Returns the Error message of the exception
|
||||||
* \return std::string The error message
|
* \return std::string The error message
|
||||||
*/
|
*/
|
||||||
std::string message() const
|
inline std::string message() const
|
||||||
{
|
{
|
||||||
return m_message;
|
return m_message;
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
/*! \brief The constructor for an FileNotFoundException
|
/*! \brief The constructor for an FileNotFoundException
|
||||||
* \param filename The path of the offending file.
|
* \param filename The path of the offending file.
|
||||||
*/
|
*/
|
||||||
FileNotFoundException(const std::string& filename) :
|
inline FileNotFoundException(const std::string& filename) :
|
||||||
Exception("FileNotFoundException:\nCouldn't not find \"" + filename + "\", please check that it exists."),
|
Exception("FileNotFoundException:\nCouldn't not find \"" + filename + "\", please check that it exists."),
|
||||||
m_filename(filename)
|
m_filename(filename)
|
||||||
{}
|
{}
|
||||||
|
@ -40,7 +40,7 @@ public:
|
||||||
/*! \brief Returns the path of the offending file.
|
/*! \brief Returns the path of the offending file.
|
||||||
* \return std::string The filename of the file including the path.
|
* \return std::string The filename of the file including the path.
|
||||||
*/
|
*/
|
||||||
std::string filename() const { return m_filename; }
|
inline std::string filename() const { return m_filename; }
|
||||||
private:
|
private:
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
/*! \brief The constructor for an InvalidOperationException
|
/*! \brief The constructor for an InvalidOperationException
|
||||||
* \param error The error message to throw
|
* \param error The error message to throw
|
||||||
*/
|
*/
|
||||||
InvalidOperationException(const std::string& error)
|
inline InvalidOperationException(const std::string& error)
|
||||||
: Exception("InvalidOperationException:\n" + error)
|
: Exception("InvalidOperationException:\n" + error)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,34 @@
|
||||||
* return 0;
|
* return 0;
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
|
* \section example_sec BinaryReader example
|
||||||
|
* \code
|
||||||
|
* #include "BinaryReader.hpp"
|
||||||
|
* #include "FileNotFoundException.hpp"
|
||||||
|
* #include "Exception.hpp"
|
||||||
|
* int main()
|
||||||
|
* {
|
||||||
|
* try
|
||||||
|
* {
|
||||||
|
* BinaryReader writer("test.bin");
|
||||||
|
* std::cout << reader.readByte() << std::endl;
|
||||||
|
* std::cout << reader.readInt32() << std::endl;
|
||||||
|
* }
|
||||||
|
* catch (FileNotFoundException e)
|
||||||
|
* {
|
||||||
|
* std::cout << e.message() << std::endl;
|
||||||
|
* }
|
||||||
|
* catch (Exception e)
|
||||||
|
* {
|
||||||
|
* std::cout << e.message() << std::endl;
|
||||||
|
* }
|
||||||
|
* catch(...)
|
||||||
|
* {
|
||||||
|
* }
|
||||||
|
* return 0;
|
||||||
|
* }
|
||||||
|
* \endcode
|
||||||
* \section Credits
|
* \section Credits
|
||||||
* Chibi Zelda: AnimeWaterFall on Deviantart
|
* Chibi Zelda: <a href="http://animewaterfall.deviantart.com/art/Chibi-Zelda-331611090">AnimeWaterFall</a> on Deviantart
|
||||||
*/
|
*/
|
||||||
#endif // __MAINPAGE_HPP__
|
#endif // __MAINPAGE_HPP__
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
class Stream
|
class Stream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! \brief Default buffer block size.
|
||||||
static const Uint32 BLOCKSZ;
|
static const Uint32 BLOCKSZ;
|
||||||
|
|
||||||
/*! \enum Endian
|
/*! \enum Endian
|
||||||
|
|
|
@ -1319,7 +1319,7 @@ MAKEINDEX_CMD_NAME = makeindex
|
||||||
# LaTeX documents. This may be useful for small projects and may help to
|
# LaTeX documents. This may be useful for small projects and may help to
|
||||||
# save some trees in general.
|
# save some trees in general.
|
||||||
|
|
||||||
COMPACT_LATEX = NO
|
COMPACT_LATEX = YES
|
||||||
|
|
||||||
# The PAPER_TYPE tag can be used to set the paper type that is used
|
# The PAPER_TYPE tag can be used to set the paper type that is used
|
||||||
# by the printer. Possible values are: a4, letter, legal and
|
# by the printer. Possible values are: a4, letter, legal and
|
||||||
|
|
|
@ -28,3 +28,6 @@ SOURCES += \
|
||||||
src/BinaryWriter.cpp \
|
src/BinaryWriter.cpp \
|
||||||
src/BinaryReader.cpp
|
src/BinaryReader.cpp
|
||||||
|
|
||||||
|
system("exec doxygen libzelda.conf")
|
||||||
|
system("cd doc/latex && make")
|
||||||
|
system("cd ../../")
|
||||||
|
|
|
@ -68,7 +68,7 @@ BinaryReader::BinaryReader(const std::string& filename)
|
||||||
|
|
||||||
done += blocksize;
|
done += blocksize;
|
||||||
std::cout << "Read " << done << " bytes" << std::endl;
|
std::cout << "Read " << done << " bytes" << std::endl;
|
||||||
}while (done < m_length);
|
}while (done < length);
|
||||||
|
|
||||||
fclose(in);
|
fclose(in);
|
||||||
m_length = length;
|
m_length = length;
|
||||||
|
|
|
@ -188,7 +188,7 @@ void Stream::seek(Int64 position, SeekOrigin origin)
|
||||||
switch (origin)
|
switch (origin)
|
||||||
{
|
{
|
||||||
case Beginning:
|
case Beginning:
|
||||||
if ((position < 0 || (Uint32)position > m_length) && !m_autoResize)
|
if ((position < 0 || (Int64)position > (Int64)m_length) && !m_autoResize)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << position;
|
ss << position;
|
||||||
|
@ -199,7 +199,7 @@ void Stream::seek(Int64 position, SeekOrigin origin)
|
||||||
m_position = position;
|
m_position = position;
|
||||||
break;
|
break;
|
||||||
case Current:
|
case Current:
|
||||||
if (((m_position + position) < 0 || (m_position + position) > m_length) && !m_autoResize)
|
if ((((Int64)m_position + position) < 0 || (m_position + position) > m_length) && !m_autoResize)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << (m_position + position);
|
ss << (m_position + position);
|
||||||
|
@ -211,7 +211,7 @@ void Stream::seek(Int64 position, SeekOrigin origin)
|
||||||
m_position += position;
|
m_position += position;
|
||||||
break;
|
break;
|
||||||
case End:
|
case End:
|
||||||
if (((m_length - position < 0) || (m_length - position) > m_length) && !m_autoResize)
|
if ((((Int64)m_length - position < 0) || (m_length - position) > m_length) && !m_autoResize)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::hex << "0x" << (m_length - position);
|
ss << std::hex << "0x" << (m_length - position);
|
||||||
|
|
Loading…
Reference in New Issue