00001 #ifndef __J2K__JOFile_HPP__
00002 #define __J2K__JOFile_HPP__
00003
00004 #include <j2k/Fred/Standard.hpp>
00005 #include <j2k/Fred/Error/JErrorController.hpp>
00006
00007 #ifdef _WIN32
00008 #include <io.h>
00009 #endif
00010
00011 #include <fcntl.h>
00012
00013 #include <sys/types.h>
00014 #include <sys/stat.h>
00015
00016
00017
00018
00019
00020
00021 class JFile {
00022 public:
00023 JFile();
00024 JFile( const char* path, const char* mode = "r", size_t recordsize = 1 );
00025 virtual ~JFile();
00026
00027 size_t getFileSize();
00028
00029 void reopen();
00030
00031 int getChar();
00032 void putChar( int c );
00033
00034 void putStr( const char* s );
00035 char* getStr( char* s, int n );
00036
00037 inline int ungetChar( int c );
00038
00039
00040 char* getFileName();
00041
00042 void getFileName( char* buffer );
00043
00044 size_t readChar( char* c );
00045 size_t read( void* ptr, size_t size, size_t n = 1 );
00046 size_t write( const void* ptr, size_t size, size_t n = 1 );
00047
00048 int eof();
00049 int flush();
00050
00051 int seek( long offset, int whence = SEEK_SET );
00052 int getpos( fpos_t* pos );
00053 int setpos( const fpos_t* pos );
00054 long tell();
00055 void rewind();
00056
00057 void setbuf( char* buf );
00058 int setvbuf( char* buf, int type, size_t sz );
00059
00060 int error();
00061 void clearError();
00062
00063 void setBegin( long offset = 0 );
00064 void addCurrent( long offset = 0 );
00065 void setEnd( long offset = 0 );
00066
00067 int print( const char* format, ... );
00068
00069 long getData( char* buffer, size_t length );
00070 size_t putData( char* buffer, long length, long blocksize );
00071
00072 private:
00073 FILE* f;
00074 FILE* F();
00075 const char* fpath;
00076 const char* fmode;
00077 size_t fpos;
00078 size_t recsize;
00079 size_t current;
00080 };
00081
00082 #endif