1/**
2 * Copyright (c) 2006-2023 LOVE Development Team
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 * 3. This notice may not be removed or altered from any source distribution.
19 **/
20
21#ifndef LOVE_FILESYSTEM_PHYSFS_FILE_H
22#define LOVE_FILESYSTEM_PHYSFS_FILE_H
23
24// LOVE
25#include "common/config.h"
26#include "filesystem/File.h"
27
28// PhysFS
29#include "libraries/physfs/physfs.h"
30
31// STD
32#include <string>
33
34namespace love
35{
36namespace filesystem
37{
38namespace physfs
39{
40
41class File : public love::filesystem::File
42{
43public:
44
45 /**
46 * Constructs an File with the given ilename.
47 * @param filename The relative filepath of the file to load.
48 **/
49 File(const std::string &filename);
50
51 virtual ~File();
52
53 // Implements love::filesystem::File.
54 using love::filesystem::File::read;
55 using love::filesystem::File::write;
56 bool open(Mode mode) override;
57 bool close() override;
58 bool isOpen() const override;
59 int64 getSize() override;
60 virtual int64 read(void *dst, int64 size) override;
61 bool write(const void *data, int64 size) override;
62 bool flush() override;
63 bool isEOF() override;
64 int64 tell() override;
65 bool seek(uint64 pos) override;
66 bool setBuffer(BufferMode bufmode, int64 size) override;
67 BufferMode getBuffer(int64 &size) const override;
68 Mode getMode() const override;
69 const std::string &getFilename() const override;
70
71private:
72
73 // filename
74 std::string filename;
75
76 // PHYSFS File handle.
77 PHYSFS_File *file;
78
79 // The current mode of the file.
80 Mode mode;
81
82 BufferMode bufferMode;
83 int64 bufferSize;
84
85}; // File
86
87} // physfs
88} // filesystem
89} // love
90
91#endif // LOVE_FILESYSTEM_PHYSFS_FILE_H
92