Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/nto/File.cpp

Go to the documentation of this file.
00001 #ifndef __J2K__File_CPP__
00002 #define __J2K__File_CPP__
00003 
00004 #include <j2k/nto/File.hpp>
00005 
00006 
00007 File::File( const char* n, int o  = O_RDONLY ) 
00008  : fd( 0 )
00009 {
00010 //      name  = new JString( n );
00011   oflag = o;
00012 
00013   fd = ::open( n, oflag );
00014   if ( fd == -1 ) {
00015     MC_OnError( errno, Error, "Cannot open track data file" )
00016   }
00017 }
00018 
00019 File::~File() 
00020 { 
00021   if ( fd   ) close( fd );
00022     // if ( name ) delete name;
00023 
00024 }
00025 
00026 size_t File::read( void* buffer, size_t sz )
00027 {
00028   int val = ::read( fd, buffer, sz );
00029   if ( val == -1 ) {
00030     MC_OnError( errno, Error, "Cannot read from track data file" )
00031   }
00032   
00033   return (size_t)val;
00034 }
00035   
00036 void File::write( const void* buffer, size_t sz )
00037 {
00038   int val = ::write( fd, buffer, sz );
00039   if ( val == -1 ) {
00040     MC_OnError( errno, Error, "Cannot write to track data file" )
00041   }
00042 
00043   if ( (size_t)val != sz ) {
00044     MC_OnError( EAGAIN, Error, "Cannot write to track data file" )
00045   }
00046 }
00047 
00048 #endif

Generated on Sun Oct 14 18:46:35 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001