int CoreIOReader::ReadU32(uint32_t *_buffer) { CoreAssert(this != NULL); if (!IsOpen()) return CC_ERR_INVALID_BUFFER; if (!_buffer) return CC_ERR_INVALID_BUFFER; #ifndef __GNUC__ MutexHolder mh(&m_ioMutex); #endif size_t retval; retval = fread(_buffer, sizeof(uint32_t), 1, m_fileInputPointer); switch (m_endianness) { case CC_ENDIAN_LITTLE: *_buffer = CC_SwapLE32(*_buffer); break; case CC_ENDIAN_BIG: *_buffer = CC_SwapBE32(*_buffer); break; case CC_ENDIAN_NATIVE: /* Do nothing */ break; } return retval; }
int CoreIOWriter::WriteU32(cc_uint32_t _data) { CoreAssert(this != NULL); if (!IsOpen()) return 0; #ifndef __GNUC__ MutexHolder mh(&m_ioMutex); #endif switch (m_endianness) { case CC_ENDIAN_LITTLE: _data = CC_SwapBE32(_data); break; case CC_ENDIAN_BIG: _data = CC_SwapLE32(_data); break; case CC_ENDIAN_NATIVE: /* Do nothing */ break; } size_t ret = fwrite(&_data, sizeof(cc_uint32_t), 1, m_fileOutputPointer); return ret; }