00001 #ifndef BYTE_FILER_CLASS
00002 #define BYTE_FILER_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00020 #include "opsysdll.h"
00021
00022
00023 class file_hider;
00024
00025 class OPSYSTEM_CLASS_STYLE byte_filer
00026 {
00027 public:
00028 byte_filer();
00030
00032 byte_filer(const istring &filename, const istring &permissions);
00034
00046 byte_filer(const char *filename, const char *permissions);
00048
00049 byte_filer(bool auto_close, void *opened);
00051
00055 ~byte_filer();
00056
00057 static size_t file_size_limit();
00059
00061 bool open(const istring &filename, const istring &permissions);
00063
00065 void close();
00067
00069 istring filename() const;
00071
00072 bool good();
00074
00075 size_t length();
00077
00080 size_t tell();
00082
00084 void flush();
00086
00087 enum origins {
00088 FROM_START,
00089 FROM_END,
00090 FROM_CURRENT
00091 };
00092
00093 bool seek(int where, origins origin = FROM_START);
00095
00099 bool eof();
00101
00102 int read(byte *buffer, int buffer_size);
00104
00106 int write(const byte *buffer, int buffer_size);
00108
00109 int read(byte_array &buffer, int desired_size);
00111 int write(const byte_array &buffer);
00113
00114 int read(istring &buffer, int desired_size);
00116
00122 int write(const istring &buffer, bool add_null = false);
00124
00128 int getline(byte *buffer, int desired_size);
00130 int getline(byte_array &buffer, int desired_size);
00132 int getline(istring &buffer, int desired_size);
00134
00135 bool truncate();
00137
00138 void *file_handle();
00140
00142 private:
00143 file_hider *_handle;
00144 istring *_filename;
00145 bool _auto_close;
00146
00147
00148 byte_filer(const byte_filer &);
00149 byte_filer &operator =(const byte_filer &);
00150 };
00151
00152 #endif
00153