byte_filer.h

Go to the documentation of this file.
00001 #ifndef BYTE_FILER_CLASS
00002 #define BYTE_FILER_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : byte_filer                                                        *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2000-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00019 
00020 #include "opsysdll.h"
00021 
00022 // forward.
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   // not to be called.
00148   byte_filer(const byte_filer &);
00149   byte_filer &operator =(const byte_filer &);
00150 };
00151 
00152 #endif
00153 

Generated on Thu Nov 20 04:29:03 2008 for HOOPLE Libraries by  doxygen 1.5.1