summaryrefslogtreecommitdiffstats
path: root/base/base_io.h
blob: bced4cffd6fe48c59efb51b0bd87f121ceaa3f38 (plain) (blame)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef BASE_IO_H
#define BASE_IO_H

#define STDIN 0
#define STDOUT 1
#define STDERR 2

#if defined(PLATFORM_LINUX)
#include "base_unix_io.h"
#elif defined(PLATFORM_WINDOWS)
#include "base_win32_io.h"
#endif // PLATFORM_LINUX || PLATFORM_WINDOWS


//-
#if defined(PLATFORM_WINDOWS)

// File I/O
#define FileLoad(arena, path) win32_file_load(arena, path)
#define FileWrite(data, path) win32_file_write(data, path)
#define FileExists(path)      win32_file_exists(path)

#define OSExit()              win32_os_exit();

//- Logging
#if defined(BASE_LOGGING)
#define Log(format, ...)      win32_log_with_args((char *)(format), ##__VA_ARGS__)
#else
#define Log(format, ...)
#endif

#elif defined(PLATFORM_LINUX) // PLATFORM_WINDOWS

//- File I/O
#define FileLoad(arena, path) unix_file_load(arena, path)
#define FileWrite(data, path) unix_file_write(data, path)
#define FileExists(path)      unix_file_exists(path)

#define OSExit() unix_os_exit();

#if defined(BASE_LOGGING)
#define Log(format, ...) unix_log_with_args((char *)(format), ##__VA_ARGS__)
#else
#define Log(format, ...)
#endif // BASE_LOGGING

#endif // File I/O

internal void
Assert(b32 expression)
{
    if(!(expression))
    {
        Log("[ASSERT] %s : %s : %s \n", __FILE__ , __LINE__, __func__ );
        OSExit();
    }
}



#endif /* BASE_IO_H */