mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Changed: #1249 Endianness problems while access to disk or memory
This commit is contained in:
parent
b925de055c
commit
51d09f375a
3 changed files with 54 additions and 0 deletions
|
@ -1224,6 +1224,11 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse,
|
||||||
fclose(Handle);
|
fclose(Handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(nOffsetFromBegining);
|
||||||
|
#endif
|
||||||
|
|
||||||
nlfseek64 (Handle, nOffsetFromBegining, SEEK_SET);
|
nlfseek64 (Handle, nOffsetFromBegining, SEEK_SET);
|
||||||
uint32 nNbFile;
|
uint32 nNbFile;
|
||||||
if (fread (&nNbFile, sizeof(uint32), 1, Handle) != 1)
|
if (fread (&nNbFile, sizeof(uint32), 1, Handle) != 1)
|
||||||
|
@ -1231,6 +1236,11 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse,
|
||||||
fclose(Handle);
|
fclose(Handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(nNbFile);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (uint32 i = 0; i < nNbFile; ++i)
|
for (uint32 i = 0; i < nNbFile; ++i)
|
||||||
{
|
{
|
||||||
// Progress bar
|
// Progress bar
|
||||||
|
@ -1259,12 +1269,22 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse,
|
||||||
fclose(Handle);
|
fclose(Handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(nFileSize2);
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32 nFilePos;
|
uint32 nFilePos;
|
||||||
if (fread (&nFilePos, sizeof(uint32), 1, Handle) != 1)
|
if (fread (&nFilePos, sizeof(uint32), 1, Handle) != 1)
|
||||||
{
|
{
|
||||||
fclose(Handle);
|
fclose(Handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(nFilePos);
|
||||||
|
#endif
|
||||||
|
|
||||||
string sTmp = toLower(string(FileName));
|
string sTmp = toLower(string(FileName));
|
||||||
if (sTmp.empty())
|
if (sTmp.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -154,6 +154,10 @@ struct BNPHeader
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(nOffsetFromBegining);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0)
|
if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0)
|
||||||
{
|
{
|
||||||
fclose (f);
|
fclose (f);
|
||||||
|
@ -167,6 +171,10 @@ struct BNPHeader
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(nNbFile);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (uint32 i = 0; i < nNbFile; ++i)
|
for (uint32 i = 0; i < nNbFile; ++i)
|
||||||
{
|
{
|
||||||
uint8 nStringSize;
|
uint8 nStringSize;
|
||||||
|
@ -189,11 +197,21 @@ struct BNPHeader
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(tmpBNPFile.Size);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1)
|
if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1)
|
||||||
{
|
{
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(tmpBNPFile.Pos);
|
||||||
|
#endif
|
||||||
|
|
||||||
Files.push_back (tmpBNPFile);
|
Files.push_back (tmpBNPFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1708,6 +1708,10 @@ bool CPatchManager::readBNPHeader(const string &SourceName, vector<SBNPFile> &Fi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(nOffsetFromBegining);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0)
|
if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0)
|
||||||
{
|
{
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -1721,6 +1725,10 @@ bool CPatchManager::readBNPHeader(const string &SourceName, vector<SBNPFile> &Fi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(nNbFile);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (uint32 i = 0; i < nNbFile; ++i)
|
for (uint32 i = 0; i < nNbFile; ++i)
|
||||||
{
|
{
|
||||||
uint8 nStringSize;
|
uint8 nStringSize;
|
||||||
|
@ -1746,12 +1754,20 @@ bool CPatchManager::readBNPHeader(const string &SourceName, vector<SBNPFile> &Fi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(tmpBNPFile.Size);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1)
|
if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1)
|
||||||
{
|
{
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
NLMISC_BSWAP32(tmpBNPFile.Pos);
|
||||||
|
#endif
|
||||||
|
|
||||||
Files.push_back (tmpBNPFile);
|
Files.push_back (tmpBNPFile);
|
||||||
}
|
}
|
||||||
fclose (f);
|
fclose (f);
|
||||||
|
|
Loading…
Reference in a new issue