00001
00002
00003
00004
00005
00006
00007 #ifndef _MIMETIC_OS_STDFILE_H
00008 #define _MIMETIC_OS_STDFILE_H
00009 #include <sys/types.h>
00010 #include <sys/stat.h>
00011 #include <fcntl.h>
00012 #include <cstdio>
00013 #include <string>
00014 #include <iterator>
00015 #include <mimetic/os/fileop.h>
00016 #include <mimetic/os/file_iterator.h>
00017
00018 namespace mimetic
00019 {
00020
00021
00022 struct StdFile: public FileOp
00023 {
00024 typedef ifile_iterator iterator;
00025 StdFile();
00026 StdFile(const std::string&, int mode = O_RDONLY);
00027 ~StdFile();
00028 operator bool() const;
00029 void open(const std::string&, int mode = O_RDONLY);
00030 void close();
00031 uint read(char*, int);
00032
00033 iterator begin();
00034 iterator end();
00035 protected:
00036 void open(int flags);
00037 bool stat();
00038
00039 std::string m_fqn;
00040 bool m_stated;
00041 struct stat m_st;
00042 int m_fd;
00043 };
00044
00045 }
00046
00047
00048 #endif
00049