1 #ifndef __MRT_FILE_H__ 2 #define __MRT_FILE_H__ 3 4 /* M-runtime for c++ 5 * Copyright (C) 2005-2008 Vladimir Menshakov 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 12 * This library 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 GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #include <string> 23 #include <stdio.h> 24 #include "base_file.h" 25 #include "fs_node.h" 26 #include "export_mrt.h" 27 28 namespace mrt { 29 30 class Chunk; 31 32 class MRTAPI File : public BaseFile, public FSNode { 33 public: 34 bool readline(std::string &str, const size_t bufsize = 1024) const; 35 36 File(); 37 ~File(); 38 39 virtual void open(const std::string &fname, const std::string &mode); 40 virtual bool opened() const; 41 42 virtual void seek(long offset, int whence) const; 43 virtual long tell() const; 44 virtual void write(const Chunk &ch) const; 45 46 virtual const off_t get_size() const; 47 virtual const size_t read(void *buf, const size_t size) const; 48 virtual void close(); 49 50 virtual bool eof() const; 51 52 inline operator FILE*() const { return _f; } 53 FILE * unlink(); //unlinks FILE* structure from this object 54 private: 55 FILE *_f; 56 }; 57 58 } 59 60 #endif 61