Main Page   Class Hierarchy   Alphabetical List   Compound List   Examples  
stdfile.h
00001 /***************************************************************************
00002     copyright            : (C) 2002-2008 by Stefano Barbato
00003     email                : stefano@codesink.org
00004 
00005     $Id: stdfile.h,v 1.9 2008-10-07 11:06:26 tat Exp $
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 // File class
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