* Fix styling

This commit is contained in:
2015-05-18 20:24:56 -07:00
parent 423a9a37d2
commit 6ee11b9a08
160 changed files with 11539 additions and 7742 deletions

View File

@@ -72,6 +72,7 @@ bool FileReader::isLittleEndian() const
void FileReader::open()
{
m_fileHandle = fopen(m_filename.c_str(), "rb");
if (!m_fileHandle)
THROW_FILE_NOT_FOUND_EXCEPTION(m_filename);
@@ -143,6 +144,7 @@ bool FileReader::readBit()
if (!m_bitValid)
{
size_t size = fread(&m_currentByte, 1, 1, m_fileHandle);
if (size != sizeof(atUint8))
THROW_IO_EXCEPTION_RETURN(false, "Error reading from file.");
@@ -152,6 +154,7 @@ bool FileReader::readBit()
atUint8 flag = (1 << m_bitShift);
m_bitShift++;
if (m_bitShift > 7)
m_bitValid = false;
@@ -173,6 +176,7 @@ atInt8 FileReader::readByte()
{
if (!isOpen())
THROW_INVALID_OPERATION_EXCEPTION_RETURN(0, "File not open for reading");
return (atInt8)readUByte();
}
@@ -180,16 +184,18 @@ atUint8* FileReader::readUBytes(atUint64 len)
{
if (!isOpen())
THROW_INVALID_OPERATION_EXCEPTION_RETURN(nullptr, "File not open for reading");
m_bitValid = false;
atUint8* val = new atUint8[len];
fread(val, 1, len, m_fileHandle);
return val;
}
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len)
{
if (!isOpen())
THROW_INVALID_OPERATION_EXCEPTION_RETURN(0, "File not open for reading");
m_bitValid = false;
return fread(buf, 1, len, m_fileHandle);
}
@@ -198,6 +204,7 @@ atInt8* FileReader::readBytes(atUint64 len)
{
if (!isOpen())
THROW_INVALID_OPERATION_EXCEPTION_RETURN(nullptr, "File not open for reading");
return (atInt8*)readUBytes(len);
}
@@ -314,6 +321,7 @@ std::string FileReader::readString(atInt32 maxlen)
atUint8 chr = readByte();
atInt32 i = 0;
while (chr != 0)
{
if (maxlen >= 0 && i >= maxlen - 1)
@@ -336,20 +344,24 @@ std::string FileReader::readUnicode(atInt32 maxlen)
std::vector<short> tmp;
atInt32 i = 0;
for(;;)
for (;;)
{
if (maxlen >= 0 && i >= maxlen - 1)
break;
short chr = readUint16();
if (chr)
tmp.push_back(chr);
else
break;
i++;
};
utf8::utf16to8(tmp.begin(), tmp.end(), back_inserter(ret));
return ret;
}