From d3477eedc113a2c126f36f41384b8921d610906a Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 8 Feb 2008 19:24:12 +0000 Subject: updated filesystem, removed inifile, updated game and tga loader minor cleanups --- src/filesystem/file.h | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'src/filesystem/file.h') diff --git a/src/filesystem/file.h b/src/filesystem/file.h index ba392de..37ac8b4 100644 --- a/src/filesystem/file.h +++ b/src/filesystem/file.h @@ -9,34 +9,41 @@ // C++ headers #include -#include namespace filesystem { -/// a class to open data files -class File : public std::ifstream { +/** + * @brief an abstract interface to handle file access + */ +class File +{ public: File(); virtual ~File(); - /// open the file for reading - virtual void open(const char * filename, std::ios_base::openmode mode = std::ios_base::in); + /// open file for reading + virtual bool open(const char * filename) = 0; - /// current filename - inline std::string name() { - return file_name; - } - - /// current full path - inline std::string path() { - return real_name; - } + /// close file + virtual void close() = 0; -private: + /// read bytes + virtual size_t read(void *buffer, size_t count) = 0; + + /// skip bytes + virtual void skip(size_t count) = 0; + + /// name of the file in the virtual filesystem + inline const std::string name() const { return file_name; } + + /// the path holding the virtual filename + inline const std::string path() const { return file_path; } + +protected: std::string file_name; - std::string real_name; -} -; // class File + + std::string file_path; +}; } // namespace filesystem -- cgit v1.2.3