summaryrefslogtreecommitdiff
path: root/src/io.cpp
blob: 488d2bdf1fddc064df46f273c0f8389f2286a717 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#if SPECIAL
#include "main.h"
#endif

static void
IO_WriteToStream(void *Address, uint64 FileSize, SDL_RWops *TestFile)
{
    uint64 Size_Written = SDL_RWwrite(TestFile, Address, 1, FileSize);

    if (Size_Written != FileSize)
        Assert(0);
}

static void
IO_ReadFromStream(void *Address, uint64 SizeToRead, SDL_RWops *File)
{
    int64 TotalBytesRead = 0;
    uint8 *Address_Playhead = (uint8 *)Address;
    while (TotalBytesRead < SizeToRead) {
        uint64 BytesRead = SDL_RWread(File, Address, 1, (SizeToRead - TotalBytesRead));
        if (BytesRead == 0)
            break;
        TotalBytesRead += BytesRead;
        Address_Playhead += BytesRead;
    }
    Assert(TotalBytesRead == SizeToRead);
}