Whitespace, cstdint types

This commit is contained in:
Bart Trzynadlowski 2016-04-02 21:32:28 +00:00
parent 9c2aff72c8
commit c7ad13fb31
2 changed files with 263 additions and 262 deletions

View file

@ -49,14 +49,14 @@ unsigned CBlockFile::ReadBytes(void *data, unsigned numBytes)
{ {
if (NULL == fp) if (NULL == fp)
return 0; return 0;
return fread(data, sizeof(UINT8), numBytes, fp); return fread(data, sizeof(uint8_t), numBytes, fp);
} }
unsigned CBlockFile::ReadDWord(UINT32 *data) unsigned CBlockFile::ReadDWord(uint32_t *data)
{ {
if (NULL == fp) if (NULL == fp)
return 0; return 0;
fread(data, sizeof(UINT32), 1, fp); fread(data, sizeof(uint32_t), 1, fp);
return 4; return 4;
} }
@ -70,23 +70,23 @@ void CBlockFile::UpdateBlockSize(void)
curPos = ftell(fp); // save current file position curPos = ftell(fp); // save current file position
fseek(fp, blockStartPos, SEEK_SET); fseek(fp, blockStartPos, SEEK_SET);
newBlockSize = curPos - blockStartPos; newBlockSize = curPos - blockStartPos;
fwrite(&newBlockSize, sizeof(UINT32), 1, fp); fwrite(&newBlockSize, sizeof(uint32_t), 1, fp);
fseek(fp, curPos, SEEK_SET); // go back fseek(fp, curPos, SEEK_SET); // go back
} }
void CBlockFile::WriteByte(UINT8 data) void CBlockFile::WriteByte(uint8_t data)
{ {
if (NULL == fp) if (NULL == fp)
return; return;
fwrite(&data, sizeof(UINT8), 1, fp); fwrite(&data, sizeof(uint8_t), 1, fp);
UpdateBlockSize(); UpdateBlockSize();
} }
void CBlockFile::WriteDWord(UINT32 data) void CBlockFile::WriteDWord(uint32_t data)
{ {
if (NULL == fp) if (NULL == fp)
return; return;
fwrite(&data, sizeof(UINT32), 1, fp); fwrite(&data, sizeof(uint32_t), 1, fp);
UpdateBlockSize(); UpdateBlockSize();
} }
@ -94,7 +94,7 @@ void CBlockFile::WriteBytes(const void *data, unsigned numBytes)
{ {
if (NULL == fp) if (NULL == fp)
return; return;
fwrite(data, sizeof(UINT8), numBytes, fp); fwrite(data, sizeof(uint8_t), numBytes, fp);
UpdateBlockSize(); UpdateBlockSize();
} }
@ -142,10 +142,10 @@ void CBlockFile::WriteBlockHeader(const char *name, const char *comment)
Block Format Block Format
------------ ------------
blockLength (UINT32) Total length of block in bytes. blockLength (uint32_t) Total length of block in bytes.
nameLength (UINT32) Length of name field including terminating 0 (up to nameLength (uint32_t) Length of name field including terminating 0 (up to
1025). 1025).
commentLength (UINT32) Same as above, but for comment string. commentLength (uint32_t) Same as above, but for comment string.
name ... Name string (null-terminated, up to 1025 bytes). name ... Name string (null-terminated, up to 1025 bytes).
comment ... Comment string (same as above). comment ... Comment string (same as above).
data ... Raw data (blockLength - total header size). data ... Raw data (blockLength - total header size).

View file

@ -28,6 +28,7 @@
#ifndef INCLUDED_BLOCKFILE_H #ifndef INCLUDED_BLOCKFILE_H
#define INCLUDED_BLOCKFILE_H #define INCLUDED_BLOCKFILE_H
#include <cstdint>
/* /*
* CBlockFile: * CBlockFile:
@ -150,10 +151,10 @@ private:
// Helper functions // Helper functions
void ReadString(char *str, unsigned strLen, unsigned maxLen); void ReadString(char *str, unsigned strLen, unsigned maxLen);
unsigned ReadBytes(void *data, unsigned numBytes); unsigned ReadBytes(void *data, unsigned numBytes);
unsigned ReadDWord(UINT32 *data); unsigned ReadDWord(uint32_t *data);
void UpdateBlockSize(void); void UpdateBlockSize(void);
void WriteByte(UINT8 data); void WriteByte(uint8_t data);
void WriteDWord(UINT32 data); void WriteDWord(uint32_t data);
void WriteBytes(const void *data, unsigned numBytes); void WriteBytes(const void *data, unsigned numBytes);
void WriteBlockHeader(const char *name, const char *comment); void WriteBlockHeader(const char *name, const char *comment);