ManaPlus
fsfuncs.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2013-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef UTILS_VIRTFSFUNCS_H
23 #define UTILS_VIRTFSFUNCS_H
24 
25 #include "fs/virtfs/rwopstypes.h"
26 
27 #include "utils/stringvector.h"
28 
29 #include "localconsts.h"
30 
31 struct SDL_RWops;
32 
33 namespace VirtFs
34 {
35 
36 struct File;
37 struct FsEntry;
38 
39 struct FsFuncs final
40 {
41  FsFuncs() :
42  close(nullptr),
43  read(nullptr),
44  write(nullptr),
46  tell(nullptr),
47  seek(nullptr),
48  exists(nullptr),
58  eof(nullptr),
63 #ifdef USE_SDL2
64  rwops_size(nullptr),
65 #endif // USE_SDL2
67  {
68  }
69 
71 
72  int (*close) (File *restrict const file);
73  int64_t (*read) (File *restrict const file,
74  void *restrict const buffer,
75  const uint32_t objSize,
76  const uint32_t objCount);
77  int64_t (*write) (File *restrict const file,
78  const void *restrict const buffer,
79  const uint32_t objSize,
80  const uint32_t objCount);
81  int64_t (*fileLength) (File *restrict const file);
82  int64_t (*tell) (File *restrict const file);
83  int (*seek) (File *restrict const file,
84  const uint64_t pos);
85  bool (*exists) (FsEntry *restrict const entry,
86  std::string filename,
87  std::string dirName);
88  bool (*getRealDir) (FsEntry *restrict const entry,
89  std::string filename,
90  std::string dirName,
91  std::string &realDir);
92  void (*enumerate) (FsEntry *restrict const entry,
93  std::string dirName,
94  StringVect &names);
95  void (*getFiles) (FsEntry *restrict const entry,
96  std::string dirName,
97  StringVect &names);
98  void (*getFilesWithDir) (FsEntry *restrict const entry,
99  const std::string &dirName,
100  StringVect &names);
101  void (*getDirs) (FsEntry *restrict const entry,
102  std::string dirName,
103  StringVect &names);
104  bool (*isDirectory) (FsEntry *restrict const entry,
105  std::string dirName,
106  bool &isDirFlag);
107  File *(*openRead) (FsEntry *restrict const entry,
108  std::string filename);
109  File *(*openWrite) (FsEntry *restrict const entry,
110  const std::string &filename);
111  File *(*openAppend) (FsEntry *restrict const entry,
112  const std::string &filename);
113  int (*eof) (File *restrict const file);
114  const char *(*loadFile) (FsEntry *restrict const entry,
115  std::string fileName,
116  int &restrict fileSize);
117 
118  RWOPSINT (*rwops_seek) (SDL_RWops *const rw,
119  const RWOPSINT offset,
120  const int whence);
121  RWOPSSIZE (*rwops_read) (SDL_RWops *const rw,
122  void *const ptr,
123  const RWOPSSIZE size,
124  const RWOPSSIZE maxnum);
125  RWOPSSIZE (*rwops_write) (SDL_RWops *const rw,
126  const void *const ptr,
127  const RWOPSSIZE size,
128  const RWOPSSIZE num);
129 #ifdef USE_SDL2
130  RWOPSINT (*rwops_size) (SDL_RWops *const rw);
131 #endif // USE_SDL2
132  int (*rwops_close) (SDL_RWops *const rw);
133 };
134 
135 } // namespace VirtFs
136 
137 #endif // UTILS_VIRTFSFUNCS_H
#define restrict
Definition: localconsts.h:165
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
#define nullptr
Definition: localconsts.h:45
int size()
Definition: emotedb.cpp:306
#define RWOPSSIZE
Definition: rwopstypes.h:32
#define RWOPSINT
Definition: rwopstypes.h:31
std::vector< std::string > StringVect
Definition: stringvector.h:29
void(* getDirs)(FsEntry *const entry, std::string dirName, StringVect &names)
Definition: fsfuncs.h:101
int(* seek)(File *const file, const uint64_t pos)
Definition: fsfuncs.h:83
int64_t(* fileLength)(File *const file)
Definition: fsfuncs.h:81
File *(* openWrite)(FsEntry *const entry, const std::string &filename)
Definition: fsfuncs.h:109
bool(* exists)(FsEntry *const entry, std::string filename, std::string dirName)
Definition: fsfuncs.h:85
void(* enumerate)(FsEntry *const entry, std::string dirName, StringVect &names)
Definition: fsfuncs.h:92
int(* rwops_write)(SDL_RWops *const rw, const void *const ptr, const int size, const int num)
Definition: fsfuncs.h:125
File *(* openAppend)(FsEntry *const entry, const std::string &filename)
Definition: fsfuncs.h:111
int64_t(* write)(File *const file, const void *const buffer, const uint32_t objSize, const uint32_t objCount)
Definition: fsfuncs.h:77
File *(* openRead)(FsEntry *const entry, std::string filename)
Definition: fsfuncs.h:107
int(* eof)(File *const file)
Definition: fsfuncs.h:113
int(* close)(File *const file)
Definition: fsfuncs.h:72
int32_t(* rwops_seek)(SDL_RWops *const rw, const int32_t offset, const int whence)
Definition: fsfuncs.h:118
const char *(* loadFile)(FsEntry *const entry, std::string fileName, int &fileSize)
Definition: fsfuncs.h:114
int64_t(* tell)(File *const file)
Definition: fsfuncs.h:82
void(* getFilesWithDir)(FsEntry *const entry, const std::string &dirName, StringVect &names)
Definition: fsfuncs.h:98
int(* rwops_read)(SDL_RWops *const rw, void *const ptr, const int size, const int maxnum)
Definition: fsfuncs.h:121
bool(* getRealDir)(FsEntry *const entry, std::string filename, std::string dirName, std::string &realDir)
Definition: fsfuncs.h:88
void(* getFiles)(FsEntry *const entry, std::string dirName, StringVect &names)
Definition: fsfuncs.h:95
int(* rwops_close)(SDL_RWops *const rw)
Definition: fsfuncs.h:132
int64_t(* read)(File *const file, void *const buffer, const uint32_t objSize, const uint32_t objCount)
Definition: fsfuncs.h:73
bool(* isDirectory)(FsEntry *const entry, std::string dirName, bool &isDirFlag)
Definition: fsfuncs.h:104
std::string fileName
Definition: testmain.cpp:39