载入中...
搜索中...
未找到
File.h
浏览该文件的文档.
1#pragma once
2
3#include "common/config.h"
4#include "filesystem/File.h"
5
6// PhysFS
7#include "physfs/physfs.h"
8
9// STD
10#include <string>
11
12namespace eve {
13namespace filesystem {
14namespace physfs {
15
17public:
22 File(std::string filename);
23 virtual ~File();
24
25 // Implements eve::filesystem::File.
28 bool open(std::string mode) override;
29 bool close() override;
30 bool isOpen() const override;
31 int64_t getSize() override;
32 int64_t read(void *dst, int64_t size) override;
33 bool write(const void *data, int64_t size) override;
34 bool flush() override;
35 bool isEOF() override;
36 int64_t tell() override;
37 bool seek(uint64_t pos) override;
38 bool setBuffer(std::string bufmode, int64_t size) override;
39 std::string getBuffer(int64_t &size) const override;
40 std::string getMode() const override;
41 std::string getFilename() const override;
42
43private:
44 // filename
45 std::string filename;
46
47 // PHYSFS File handle.
48 PHYSFS_File *file;
49
50 // The current mode of the file.
51 std::string mode;
52
53 std::string bufferMode;
54 int64_t bufferSize;
55
56}; // File
57
58} // namespace physfs
59} // namespace filesystem
60} // namespace eve
Light2D::Data * data
A File interface, providing generic means of reading from and writing to files.
Definition File.h:14
virtual FileData * read(int64_t size=ALL)
Reads data from the file and allocates a Data object.
Definition File.cpp:9
virtual bool write(const void *data, int64_t size)=0
Writes data into the File.
bool isEOF() override
Checks whether we are currently at end-of-file.
Definition File.cpp:153
std::string getFilename() const override
Gets the filename for this File, or empty string if none.
Definition File.cpp:195
std::string getMode() const override
Gets the current mode of the File.
Definition File.cpp:197
bool close() override
Closes the file.
Definition File.cpp:77
bool open(std::string mode) override
Opens the file in a certain mode.
Definition File.cpp:28
bool seek(uint64_t pos) override
Seeks to a certain position in the File.
Definition File.cpp:161
bool setBuffer(std::string bufmode, int64_t size) override
Sets the buffering mode for the file. When buffering is enabled,
Definition File.cpp:163
virtual ~File()
Destructor.
Definition File.cpp:24
bool write(const void *data, int64_t size) override
Writes data into the File.
Definition File.cpp:118
int64_t read(void *dst, int64_t size) override
Reads data into the destination buffer.
Definition File.cpp:101
bool flush() override
Flushes the currently buffered file data to disk. Only applicable in write mode.
Definition File.cpp:137
int64_t getSize() override
Gets the size of the file.
Definition File.cpp:88
int64_t tell() override
Gets the current position in the File.
Definition File.cpp:155
bool isOpen() const override
Gets whether the file is open.
Definition File.cpp:86
std::string getBuffer(int64_t &size) const override
Definition File.cpp:190
Definition Build.cpp:11