-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfileIO.h
82 lines (59 loc) · 2.06 KB
/
fileIO.h
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* Copyright (C) fastman92 <[email protected]>, website: http://fastman92.com
* Licensed under the MIT License, see LICENSE at top level directory.
*
*/
#include <stdio.h>
#include <stdint.h>
#ifdef IS_PLATFORM_WIN
#include <Windows.h>
#endif
#ifdef IS_PLATFORM_ANDROID
#include <sys/stat.h>
#endif
#include <sys/stat.h>
// Loads line from file without commas
bool LoadLineWithoutCommas(char * str, int num, FILE * stream);
// Returns file size
int64_t GetFileSize(const char* path);
// Returns file size
int64_t GetFileSize(const wchar_t* path);
#ifdef IS_PLATFORM_WIN
// Browses a directory and executes a function for each file
// if called function returns true, files aren't scanned anymore
bool BrowseDirectory(const char* dirPath, bool(*func)(const char* filename, void* pUserData), void* pUserData = NULL);
// Opens directory if exists or creates and opens directory if it doesn't initially exists
bool OpenOrCreateDirectory(const char* dirname);
DWORD GetFilePointer(HANDLE hFile);
LONGLONG GetFilePointerEx(HANDLE hFile);
#endif
bool FileExistsA(const char* szPath);
bool FileExistsW(const wchar_t szPath);
// Returns pointer to filename from path
char* GetFilenameFromPath(const char* path);
// Reads 4 byte aligned string
void FileRead4byteAlignedString(FILE* fp, char* str);
// Writes 4 byte aligned string
void FileWrite4byteAlignedString(FILE* fp, const char* str);
// Reads int32
uint32_t FileReadInt32(FILE* fp);
// Reads float
float FileReadFloat(FILE* fp);
// Writes float
void FileWriteFloat(FILE* fp, float value);
// Writes int32
void FileWriteInt32(FILE* fp, int32_t value);
// Writes Pascal string
void FileWritePascalString(FILE* fp, const char* str);
// Reads Pascal string
void FileReadPascalString(FILE* fp, char* outputStr, unsigned int bufferSize);
// Sets a current directory
bool SetCurrentWorkingDirectory_OS_independent(const char* directoryPath);
#ifdef IS_PLATFORM_WIN
// Create directory recursively
int mkdir_p(const char *path);
#endif
#ifdef IS_PLATFORM_ANDROID
// Create directory recursively
int mkdir_p(const char *path, mode_t mode);
#endif