coastline 0.0.4
Loading...
Searching...
No Matches
fileio.h
Go to the documentation of this file.
1#ifndef COASTLINE_PLATFORM_WIN_FILEIO_H
2#define COASTLINE_PLATFORM_WIN_FILEIO_H
3
9
10#include <stddef.h>
11#include <stdio.h>
12#ifndef __cplusplus
13#include <stdbool.h>
14#endif
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
30void ReadEntireFile(void *buffer, const char *path, int size);
31
33typedef struct GameFile {
34 FILE *pFile;
35 char *pszPath;
37
46extern int g_bVerboseFileTrace;
47
59void *CHK_AllocateMemory(size_t nSize, const char *szCaller);
60
71void *CHK_ReAllocateMemory(void *pMemory, size_t nSize, const char *szCaller);
72
83int CHK_FileExists(const char *pszPath);
84
95GameFile *CHK_FReadOpen(const char *pszPath);
96
101GameFile *CHK_FWriteOpen(const char *path, const char *mode);
102
107void CHK_FPutS(const char *text, GameFile *file);
108
120bool FCHK_FRead(void *pBuffer, size_t nSize, size_t nCount, GameFile *pFile);
121
134void *CHK_FRead(void *pBuffer, size_t nSize, size_t nCount, GameFile *pFile);
135
145
159char *FileReadLine(char *pszLine, int nSize, GameFile *pFile);
160
169void CHK_FClose(GameFile *pFile);
170
171#ifdef __cplusplus
172}
173#endif
174
175#endif // COASTLINE_PLATFORM_WIN_FILEIO_H
bool FCHK_FRead(void *pBuffer, size_t nSize, size_t nCount, GameFile *pFile)
Read items of a file.
void CHK_FPutS(const char *text, GameFile *file)
Write a string, reporting a failure before ending the process.
void * CHK_ReAllocateMemory(void *pMemory, size_t nSize, const char *szCaller)
Resize an allocation, ending the process on failure for a nonzero size.
int CHK_FileExists(const char *pszPath)
Whether a file can be opened for reading.
char * FileReadLine(char *pszLine, int nSize, GameFile *pFile)
Read a line of a file.
int g_bVerboseFileTrace
Whether the routines write each file they open or close to the debugger.
GameFile * CHK_FWriteOpen(const char *path, const char *mode)
Open a file in the requested mode, reporting a failure before ending the process.
GameFile * CHK_FReadOpen(const char *pszPath)
Open a file for reading in binary mode.
void CHK_FClose(GameFile *pFile)
Close a file and free it.
void ReadEntireFile(void *buffer, const char *path, int size)
Read size bytes from path into buffer, or the entire file when size is negative.
long GetFileLength(GameFile *pFile)
The length of a file, leaving its position unchanged.
void * CHK_AllocateMemory(size_t nSize, const char *szCaller)
Allocate memory, ending the process when none is left.
void * CHK_FRead(void *pBuffer, size_t nSize, size_t nCount, GameFile *pFile)
Read items of a file.
A file opened by the checked read or write routines.
Definition fileio.h:33
FILE * pFile
Definition fileio.h:34
char * pszPath
Definition fileio.h:35