File.h

Go to the documentation of this file.
00001 #ifndef __FILE_H__
00002 #define __FILE_H__
00003 
00004 /*
00005 
00006 $Id$
00007 
00008 */
00009 
00010 #include <map>
00011 
00012 #include "NamedObject.h"
00013 
00014 using namespace std;
00015 
00016 typedef enum
00017 {
00018   FILE_DIR     = 'd' << 24,
00019   FILE_READ    = 'r' << 16,
00020   FILE_WRITE   = 'w' << 8,
00021   FILE_EXECUTE = 'x';
00022 } FilePermission;
00023 
00024 typedef struct
00025 {
00026   FilePermission owner;
00027   FilePermission group;
00028   FilePermission others;
00029 } FilePermissions;
00030 
00031 static const FilePermission FILE_PERMISSIONS_DEFAULT = { FILE_READ | FILE_WRITE, FILE_READ, FILE_READ };
00032 
00033 class File : public NamedObject
00034 {
00035 
00036   PYLON_OBJECT
00037 
00038 public:
00039 
00040   static int open(const String &path, File **file);
00041 
00042   static int create(const String &path, File **file,
00043                     const FilePermissions &permissions = FILE_PERMISSIONS_DEFAULT,
00044                     const String &manual = "");
00045 
00046   static int unlink(const String &path);
00047 
00048   String path() const;
00049   String dir() const;
00050 
00051   FilePermissions permissions() const;
00052   int setPermissions(const FilePermissions &permissions);
00053 
00054   unsigned int position() const;
00055   int seek(unsigned int pos);
00056 
00057   int data(String &d) const = 0;
00058   int setData(const String &d) const = 0;
00059 
00060   int read(String &buff, unsigned int size) const = 0;
00061   int write(const String &buff) const = 0;
00062 
00063 protected:
00064 
00065   File(const String &path, const FilePermissions &permissions = FILE_PERMISSIONS_DEFAULT, const String &manual = "");
00066   virtual ~File();
00067 
00068 private:
00069 
00070   typedef map<String, File *> FileList;
00071 
00072   FileList _files;
00073 };
00074 
00075 #endif

Generated on Thu Sep 6 20:11:25 2007 for Pylon Application Platform by  doxygen 1.5.1