mirror of https://github.com/libAthena/athena.git
added seek directive to fixed-length string reads
This commit is contained in:
parent
3dfb001f3d
commit
e641dbbe4b
2
PKGBUILD
2
PKGBUILD
|
@ -1,7 +1,7 @@
|
|||
# PKGBUILD for libAthena
|
||||
_pkgname=libathena
|
||||
pkgname=$_pkgname-git
|
||||
pkgver=1.1.0.35.gfd3db3e
|
||||
pkgver=1.1.0.37.g3dfb001
|
||||
pkgrel=1
|
||||
pkgdesc="Basic cross platform IO library"
|
||||
arch=('i686' 'x86_64')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# PKGBUILD for atdna
|
||||
_pkgname=atdna
|
||||
pkgname=$_pkgname-git
|
||||
pkgver=1.1.0.36.g242a069
|
||||
pkgver=1.1.0.37.g3dfb001
|
||||
pkgrel=1
|
||||
pkgdesc="Companion DNA utility for libAthena"
|
||||
arch=('i686' 'x86_64')
|
||||
|
|
|
@ -340,71 +340,72 @@ atVec4f FileReader::readVec4f()
|
|||
return val;
|
||||
}
|
||||
|
||||
std::string FileReader::readString(atInt32 maxlen)
|
||||
std::string FileReader::readString(atInt32 fixedLen)
|
||||
{
|
||||
std::string ret;
|
||||
|
||||
atUint8 chr = readByte();
|
||||
|
||||
atInt32 i = 0;
|
||||
|
||||
while (chr != 0)
|
||||
atInt32 i;
|
||||
for (i = 0 ; chr != 0 ; ++i)
|
||||
{
|
||||
if (maxlen >= 0 && i >= maxlen - 1)
|
||||
if (fixedLen >= 0 && i >= fixedLen - 1)
|
||||
break;
|
||||
|
||||
ret += chr;
|
||||
chr = readByte();
|
||||
i++;
|
||||
}
|
||||
|
||||
if (fixedLen >= 0 && i < fixedLen)
|
||||
seek(fixedLen - i);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::wstring FileReader::readWString(atInt32 maxlen)
|
||||
std::wstring FileReader::readWString(atInt32 fixedLen)
|
||||
{
|
||||
std::wstring ret;
|
||||
atUint16 chr = readUint16();
|
||||
|
||||
atInt32 i = 0;
|
||||
|
||||
while (chr != 0)
|
||||
atInt32 i;
|
||||
for (i = 0 ; chr != 0 ; ++i)
|
||||
{
|
||||
if (maxlen >= 0 && i >= maxlen - 1)
|
||||
if (fixedLen >= 0 && i >= fixedLen - 1)
|
||||
break;
|
||||
|
||||
ret += chr;
|
||||
chr = readUint16();
|
||||
i++;
|
||||
}
|
||||
|
||||
if (fixedLen >= 0 && i < fixedLen)
|
||||
seek(fixedLen - i);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string FileReader::readUnicode(atInt32 maxlen)
|
||||
std::string FileReader::readUnicode(atInt32 fixedLen)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION_RETURN(std::string(), "File not open for reading");
|
||||
|
||||
std::string ret;
|
||||
std::vector<short> tmp;
|
||||
|
||||
atInt32 i = 0;
|
||||
|
||||
for (;;)
|
||||
std::vector<atUint16> tmp;
|
||||
atInt32 i;
|
||||
for (i = 0 ;; ++i)
|
||||
{
|
||||
if (maxlen >= 0 && i >= maxlen - 1)
|
||||
if (fixedLen >= 0 && i >= fixedLen - 1)
|
||||
break;
|
||||
|
||||
short chr = readUint16();
|
||||
atUint16 chr = readUint16();
|
||||
|
||||
if (chr)
|
||||
tmp.push_back(chr);
|
||||
else
|
||||
break;
|
||||
|
||||
i++;
|
||||
};
|
||||
|
||||
if (fixedLen >= 0 && i < fixedLen)
|
||||
seek(fixedLen - i);
|
||||
|
||||
utf8::utf16to8(tmp.begin(), tmp.end(), back_inserter(ret));
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -493,7 +493,7 @@ atVec4f MemoryReader::readVec4f()
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string MemoryReader::readUnicode(atInt32 maxlen)
|
||||
std::string MemoryReader::readUnicode(atInt32 fixedLen)
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
@ -502,11 +502,10 @@ std::string MemoryReader::readUnicode(atInt32 maxlen)
|
|||
std::vector<short> tmp;
|
||||
atUint16 chr = readUint16();
|
||||
|
||||
atInt32 i = 0;
|
||||
|
||||
for (;;)
|
||||
atInt32 i;
|
||||
for (i = 0 ;; ++i)
|
||||
{
|
||||
if (maxlen >= 0 && i >= maxlen - 1)
|
||||
if (fixedLen >= 0 && i >= fixedLen - 1)
|
||||
break;
|
||||
|
||||
if (!chr)
|
||||
|
@ -514,50 +513,54 @@ std::string MemoryReader::readUnicode(atInt32 maxlen)
|
|||
|
||||
tmp.push_back(chr);
|
||||
chr = readUint16();
|
||||
i++;
|
||||
}
|
||||
|
||||
if (fixedLen >= 0 && i < fixedLen)
|
||||
seek(fixedLen - i);
|
||||
|
||||
utf8::utf16to8(tmp.begin(), tmp.end(), back_inserter(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string MemoryReader::readString(atInt32 maxlen)
|
||||
std::string MemoryReader::readString(atInt32 fixedLen)
|
||||
{
|
||||
std::string ret;
|
||||
atUint8 chr = readByte();
|
||||
|
||||
atInt32 i = 0;
|
||||
|
||||
while (chr != 0)
|
||||
atInt32 i;
|
||||
for (i = 0 ; chr != 0 ; ++i)
|
||||
{
|
||||
if (maxlen >= 0 && i >= maxlen - 1)
|
||||
if (fixedLen >= 0 && i >= fixedLen - 1)
|
||||
break;
|
||||
|
||||
ret += chr;
|
||||
chr = readByte();
|
||||
i++;
|
||||
}
|
||||
|
||||
if (fixedLen >= 0 && i < fixedLen)
|
||||
seek(fixedLen - i);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::wstring MemoryReader::readWString(atInt32 maxlen)
|
||||
std::wstring MemoryReader::readWString(atInt32 fixedLen)
|
||||
{
|
||||
std::wstring ret;
|
||||
atUint16 chr = readUint16();
|
||||
|
||||
atInt32 i = 0;
|
||||
|
||||
while (chr != 0)
|
||||
atInt32 i;
|
||||
for (i = 0 ; chr != 0 ; ++i)
|
||||
{
|
||||
if (maxlen >= 0 && i >= maxlen - 1)
|
||||
if (fixedLen >= 0 && i >= fixedLen - 1)
|
||||
break;
|
||||
|
||||
ret += chr;
|
||||
chr = readUint16();
|
||||
i++;
|
||||
}
|
||||
|
||||
if (fixedLen >= 0 && i < fixedLen)
|
||||
seek(fixedLen - i);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue