Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <System/cmtkCompressedStream.h>
00034
00035 #include <stdlib.h>
00036 #include <stdio.h>
00037 #include <errno.h>
00038
00039 namespace
00040 cmtk
00041 {
00042
00045
00046 CompressedStream::File::File( const char* filename )
00047 {
00048 this->m_File = fopen( filename, CMTK_FILE_MODE );
00049 if ( !this->m_File )
00050 {
00051 throw 0;
00052 }
00053 }
00054
00055 void
00056 CompressedStream::File::Close()
00057 {
00058 fclose( this->m_File );
00059 }
00060
00061 void
00062 CompressedStream::File::Rewind ()
00063 {
00064 rewind( this->m_File );
00065 this->CompressedStream::ReaderBase::Rewind();
00066 }
00067
00068 int
00069 CompressedStream::File::Seek ( const long int offset, int whence )
00070 {
00071 return fseek( this->m_File, offset, whence );
00072 }
00073
00074 size_t
00075 CompressedStream::File::Read( void *data, size_t size, size_t count )
00076 {
00077 const size_t result = fread( data, size, count, this->m_File );
00078 this->m_BytesRead += result;
00079 return result / size;
00080 }
00081
00082 bool
00083 CompressedStream::File::Get ( char &c)
00084 {
00085 const int data = fgetc( this->m_File );
00086 if ( data != EOF )
00087 {
00088 c=(char) data;
00089 ++this->m_BytesRead;
00090 return true;
00091 }
00092
00093 return false;
00094 }
00095
00096 int
00097 CompressedStream::File::Tell () const
00098 {
00099 return ftell( this->m_File );
00100 }
00101
00102 bool
00103 CompressedStream::File::Feof () const
00104 {
00105 return (feof( this->m_File ) != 0);
00106 }
00107
00108 }