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

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