00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _FILEPROPERTY_HH_
00024 #define _FILEPROPERTY_HH_
00025
00026 #include "property.hh"
00027 #include <sys/types.h>
00028 #include <sys/stat.h>
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class PROPERTY_API FileProperty : public virtual LocalProperty
00040 {
00041 public:
00042 class FileAccessError : public runtime_error {
00043 public:
00044 FileAccessError(const string& s) : runtime_error(s) { };
00045 };
00046
00047 private:
00048 FILE* filehandle;
00049 string filename;
00050 struct stat status;
00051 bool readonly;
00052 void checkOpenFile() throw (FileAccessError);
00053
00054 public:
00055
00056 FileProperty(MetaObject* superobject);
00057
00058
00059 FileProperty(MetaObject* superobject, const string& filename, const string& datatype = "?");
00060
00061 ~FileProperty();
00062
00063
00064 static void registerExtenders();
00065
00066
00067 static MetaObject* new_FileProperty(MetaObject* superobject, const string& type);
00068
00069
00070
00071
00072 virtual void setFileBackend(const string& filename, const string& filetype = "?") throw(FileAccessError);
00073
00074
00075 virtual string getFileBackend();
00076
00077 virtual int getRawLength() throw(FileAccessError);
00078 virtual void readRaw(string& target, int start, int length) throw(FileAccessError);
00079 virtual void read(string& target, int start, int length) throw(FileAccessError) ;
00080 virtual void write(int start, const string& newdata) throw(FileAccessError);
00081 virtual void replace(const string& newdata, const string& newtype = "?") throw(FileAccessError);
00082 };
00083
00084 #endif