// File : SkyArchive.cpp
//------------------------------------------------------------------------------
// SkyWorks : Copyright 2002 Mark J. Harris and
-// The University of North Carolina at Chapel Hill
+// The University of North Carolina at Chapel Hill
//------------------------------------------------------------------------------
// Permission to use, copy, modify, distribute and sell this software and its
// documentation for any purpose is hereby granted without fee, provided that
*
* Implementation of class SkyArchive.
*/
+
+#include <plib/ul.h>
#include "SkyArchive.hpp"
#include <assert.h>
const SkyArchiveEntry* pEntry = _FindEntry(pName, index, INT16_TYPE);
if (pEntry)
{
- short* pData = (short*)(pEntry->pData);
- *pInt16 = *pData;
+ unsigned short* pData = (unsigned short*)(pEntry->pData);
+ *pInt16 = ulEndianLittle16(*pData);
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
const SkyArchiveEntry* pEntry = _FindEntry(pName, index, INT32_TYPE);
if (pEntry)
{
- int* pData = (int*)(pEntry->pData);
- *pInt32 = *pData;
+ unsigned int* pData = (unsigned int*)(pEntry->pData);
+ *pInt32 = ulEndianLittle32(*pData);
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
if (pEntry)
{
unsigned short* pData = (unsigned short*)(pEntry->pData);
- *pUInt16 = *pData;
+ *pUInt16 = ulEndianLittle16(*pData);
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
if (pEntry)
{
unsigned int* pData = (unsigned int*)(pEntry->pData);
- *pUInt32 = *pData;
+ *pUInt32 = ulEndianLittle32(*pData);
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
if (pEntry)
{
float* pData = (float*)(pEntry->pData);
- *pFloat32 = *pData;
+ *pFloat32 = ulEndianLittleFloat(*pData);
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
if (pEntry)
{
double* pData = (double*)(pEntry->pData);
- *pFloat64 = *pData;
+ *pFloat64 = ulEndianLittleDouble(*pData);
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
// load the first record
SkyArchiveFileEntry thisItem;
size_t iNumItemsRead = fread((void*)&thisItem, sizeof(SkyArchiveFileEntry), 1, pSrcFile);
- if (1 > iNumItemsRead)
+ if (!iNumItemsRead)
FAIL_RETURN_MSG(SKYRESULT_FAIL, "Error: SkyArchive::_Load(): failed to read Archive header.");
-
+
+ unsigned int ui = thisItem.iDataSize;
+ thisItem.iDataSize = ulEndianLittle32(ui);
+
_pName = new char[::strlen(thisItem.pName)+1];
::strcpy( _pName, thisItem.pName);
iNumItemsRead = fread((void*)&embeddedItem, sizeof(SkyArchiveFileEntry), 1, pSrcFile);
if (1 > iNumItemsRead)
FAIL_RETURN_MSG(SKYRESULT_FAIL, "Error: SkyArchive::_Load(): failed to read embedded archive item.");
+
+ unsigned int ui = embeddedItem.iDataSize;
+ embeddedItem.iDataSize = ulEndianLittle32(ui);
+
switch( embeddedItem.type)
{