base/zz_file.h

Go to the documentation of this file.
00001 /* libzz
00002  *
00003  * This program is distributed under the GNU General Public License, version 2.
00004  * A copy of this license is included with this source.
00005  *
00006  * Copyright 2000-2006, Toni Thomsson <toni@tonjac.org> 
00007 */
00008 
00009 #ifndef zz_file_h
00010 #define zz_file_h
00011 
00012 #include <zz_export.h>
00013 #include <stdio.h>
00014 
00015 #ifdef _WIN32
00016         #include <io.h>
00017         #include <conio.h>
00018         #include <sys\types.h>
00019         #include <sys\stat.h>       /* _S_ constant definitions */
00020         #include <windows.h>
00021 #else
00022         #include <sys/types.h>
00023         #include <sys/stat.h>       /* _S_ constant definitions */
00024         #include <unistd.h>
00025 #endif
00026 
00027 #include <time.h>
00028 #include <stdio.h>
00029 #include <fcntl.h>          /* _O_ constant definitions */
00030 #include <malloc.h>
00031 #include <errno.h>
00032 #include <zz_string.h>
00033 #include <zz_exception.h>
00034 
00035 
00036 #ifdef _REMOTECOPY
00037 extern "C"
00038 {
00039         #include <dsrcpdll.h>
00040 }
00041 #endif
00042 
00043 // Description: Storlek på läs buffer
00044 #define BUFFLEN 16*1024
00045 
00046 /*
00047         Description:
00048         Kapsling av en fil
00049 
00050         Author: 
00051         Toni Thomsson, toni@tonjac.org
00052 
00053         Library:
00054         libzz.a (HPUX) libzz.lib (win32)
00055 
00056         Platform:
00057         HPUX, win32
00058 */
00059 class ZZ_API CzzFile
00060 {
00061 
00062 public:
00063 
00064         /*
00065                 Description:
00066                 Skapar en filbehållare
00067 
00068                 Remarks:
00069                 Skapar filobjekt mha en sökväg
00070 
00071         */
00072         CzzFile( const char* path // IN, sökväg
00073                                 );
00074 
00075         // Description: Destruktor
00076         // Remarks: Stänger filen om den är öppen
00077         ~CzzFile();
00078 
00079         // Description: Filstorlek
00080         size_t Size( void );
00081 
00082         // Description: Tid
00083         time_t Time( void );
00084 
00085         // Description: Öppnar filen
00086         void Open( const char* mode // IN, mode (a,w,r + b) se fopen()
00087                                 );
00088         // Description: Läs block
00089         size_t Read( void* p,           // IN, buffert
00090                                         size_t size     // IN, storlek på buffert
00091                                         );
00092 
00093         // Description: Skriv block
00094         size_t Write( void* p,          // IN, buffert
00095                                         size_t size     // IN, storlek på buffert
00096                                         );
00097 
00098         // Description: Stäng filen
00099         void Close( void );
00100 
00101         // Description: Kontrollerar om filen finns
00102         bool Exist( void );
00103 
00104         // Description: Kopiera filen
00105         void CopyTo( const char* path // IN, destination
00106                                         );
00107 
00108         FILE* GetHandle( void );
00109 
00110 #ifdef _REMOTECOPY
00111 
00112         // Description: Kopiera filen
00113         // Remarks: Endast win32
00114         void RemoteCopy( const char* url // IN, url
00115                                                 );
00116 #endif
00117 
00118         // Description: Döp om filen
00119         void Rename( const char* newname // IN, nytt namn
00120                                         );
00121         
00122         // Description: Radera filen
00123         void Delete( void );
00124         
00125         // Description: Sökväg
00126         CzzString& GetPath( void );
00127 
00128         // Description: Ändra sökväg
00129         void SetPath( const char* path );
00130         
00131 protected:
00132 
00133         FILE* m_Handle;
00134         CzzString m_Path;
00135         CzzString m_Mode;
00136         bool m_Open;
00137         size_t m_Size;
00138         time_t m_Time;
00139 
00140 private:
00141         int Copy( const char *source, const char *target );
00142 };
00143 
00144 #endif // zz_file_h
00145 
00146 
00147 

Generated on Thu Sep 21 21:45:41 2006 for tonjac.org MINI/C++ library by  doxygen 1.4.6-NO