Main Page   Class Hierarchy   Alphabetical List   Compound List   Examples  

stdfile.h

00001 /***************************************************************************
00002     copyright            : (C) 2002-2005 by Stefano Barbato
00003     email                : stefano@codesink.org
00004 
00005     $Id: stdfile.h,v 1.8 2005/02/23 10:26:15 tat Exp $
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 #ifndef _MIMETIC_OS_STDFILE_H
00017 #define _MIMETIC_OS_STDFILE_H
00018 #include <sys/types.h>
00019 #include <sys/stat.h>
00020 #include <fcntl.h>
00021 #include <cstdio>
00022 #include <string>
00023 #include <iterator>
00024 #include <mimetic/os/fileop.h>
00025 #include <mimetic/os/file_iterator.h>
00026 
00027 namespace mimetic
00028 {
00029 
00030 // File class
00031 struct StdFile: public FileOp
00032 {
00033     typedef ifile_iterator iterator;
00034     StdFile();
00035     StdFile(const std::string&, int mode = O_RDONLY);
00036     ~StdFile();
00037     operator bool() const;
00038     void open(const std::string&, int mode = O_RDONLY);
00039     void close();
00040     uint read(char*, int);
00041 
00042     iterator begin();
00043     iterator end();
00044 protected:
00045     void open(int flags);
00046     bool stat();
00047 
00048     std::string m_fqn;
00049     bool m_stated;
00050     struct stat m_st;
00051     int m_fd;
00052 };
00053 
00054 }
00055 
00056 
00057 #endif
00058