GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/fs/virtfs/fsfuncs.h Lines: 2 2 100.0 %
Date: 2021-03-17 Branches: 0 0 0.0 %

Line Branch Exec Source
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
2
    FsFuncs() :
42
        close(nullptr),
43
        read(nullptr),
44
        write(nullptr),
45
        fileLength(nullptr),
46
        tell(nullptr),
47
        seek(nullptr),
48
        exists(nullptr),
49
        getRealDir(nullptr),
50
        enumerate(nullptr),
51
        getFiles(nullptr),
52
        getFilesWithDir(nullptr),
53
        getDirs(nullptr),
54
        isDirectory(nullptr),
55
        openRead(nullptr),
56
        openWrite(nullptr),
57
        openAppend(nullptr),
58
        eof(nullptr),
59
        loadFile(nullptr),
60
        rwops_seek(nullptr),
61
        rwops_read(nullptr),
62
        rwops_write(nullptr),
63
#ifdef USE_SDL2
64
        rwops_size(nullptr),
65
#endif  // USE_SDL2
66
2
        rwops_close(nullptr)
67
    {
68
    }
69
70
    A_DELETE_COPY(FsFuncs)
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