Repository navigation
Expand file tree
/
Copy pathFile.h
More file actions
100 lines (83 loc) · 2.65 KB
/
Copy pathFile.h
File metadata and controls
100 lines (83 loc) · 2.65 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Copyright (c) scott.cgi All Rights Reserved.
*
* This source code belongs to project Mojoc, which is a pure C Game Engine hosted on GitHub.
* The Mojoc Game Engine is licensed under the MIT License, and will continue to be iterated with coding passion.
*
* License : https://github.com/scottcgi/Mojoc/blob/master/LICENSE
* GitHub : https://github.com/scottcgi/Mojoc
* CodeStyle: https://github.com/scottcgi/Mojoc/blob/master/Docs/CodeStyle.md
*
* Since : 2013-8-27
* Update : 2019-1-8
* Author : scott.cgi
*/
#ifndef FILE_H
#define FILE_H
#include <stddef.h>
#include "Engine/Toolkit/HeaderUtils/Define.h"
/**
* Related to platform directory.
*
* Android: assets files
* IOS : NSBundle files
*/
typedef struct File File;
/**
* Resource File access API.
*/
struct AFile
{
/**
* Open a file from platform resource directory by file path.
*
* resourceFilePath:
* Android: assets
* IOS : NSBundle
*
* return NULL if open file error.
*/
File* (*Open) (const char* resourceFilePath);
/**
* Open a file descriptor from platform resource directory by file path.
* it can be used to read the file data.
*
* resourceFilePath:
* Android: assets
* IOS : NSBundle
*
* returns < 0 if direct fd access is not possible (for example, if the file is compressed).
*/
int (*OpenFileDescriptor) (const char* resourceFilePath, long* outStart, long* outLength);
/**
* Close an opened file connection, free any related resources.
*/
void (*Close) (File* file);
/**
* Return file length.
*/
long (*GetLength) (File* file);
/**
* Read count bytes of data from the current offset.
* return the number of bytes read, zero on EOF, or < 0 on error, always need to close file.
*/
int (*Read) (File* file, void* buffer, size_t count);
/**
* Seek to the specified offset.
* the whence uses the same constants (SEEK_SET, SEEK_CUR, SEEK_END) as fseek().
*
* return the new position on success, or -1 on error, always need to close file.
*/
long (*Seek) (File* file, long offset, int whence);
/**
* The internal data path related to platform directory.
* if outPathLength not NULL, will set the strlen(internalDataPath).
*
* internalDataPath:
* Android: internal data directory
* IOS : document data directory
*/
const char* (*GetInternalDataPath)(int* outPathLength);
};
extern struct AFile AFile[1];
#endif