#include <filehandler.h>
Inheritance diagram for RawHandler:


Public Member Functions | |
| RawHandler () | |
| ~RawHandler () | |
| bool | FileIsOpen () |
| bool | Create (const string &filename) |
| int | Write (const Frame &frame) |
| int | Close () |
| off_t | GetFileSize () |
| int | GetTotalFrames () |
| bool | Open (const char *s) |
| int | GetFrame (Frame &frame, int frameNum) |
Public Attributes | |
| int | fd |
Private Attributes | |
| int | numBlocks |
|
|
Definition at line 329 of file filehandler.cc. References FileHandler::extension.
|
|
|
Definition at line 335 of file filehandler.cc. References Close(). 00336 {
00337 Close();
00338 }
|
|
|
Implements FileHandler. Definition at line 366 of file filehandler.cc. References fd. Referenced by ~RawHandler(). 00367 {
00368 if ( fd != -1 )
00369 {
00370 close( fd );
00371 fd = -1;
00372 }
00373 return 0;
00374 }
|
|
|
Implements FileHandler. Definition at line 347 of file filehandler.cc. References fd, and FileTracker::GetInstance(). 00348 {
00349 fd = open( filename.c_str(), O_CREAT | O_TRUNC | O_RDWR | O_NONBLOCK, 0644 );
00350 if ( fd != -1 )
00351 {
00352 FileTracker::GetInstance().Add( filename.c_str() );
00353 this->filename = filename;
00354 }
00355 return ( fd != -1 );
00356 }
|
|
|
Implements FileHandler. Definition at line 341 of file filehandler.cc. References fd. 00342 {
00343 return fd != -1;
00344 }
|
|
|
Implements FileHandler. Definition at line 377 of file filehandler.cc. References fd. Referenced by GetTotalFrames(). 00378 {
00379 struct stat file_status;
00380 fstat( fd, &file_status );
00381 return file_status.st_size;
00382 }
|
|
||||||||||||
|
Implements FileHandler. Definition at line 406 of file filehandler.cc. References Frame::data, fail_if, fd, and numBlocks. 00407 {
00408 assert( fd != -1 );
00409 int size = 480 * numBlocks;
00410 if ( frameNum < 0 )
00411 return -1;
00412 off_t offset = ( ( off_t ) frameNum * ( off_t ) size );
00413 fail_if( lseek( fd, offset, SEEK_SET ) == ( off_t ) - 1 );
00414 if ( read( fd, frame.data, size ) > 0 )
00415 {
00416 frame.ExtractHeader();
00417 return 0;
00418 }
00419 else
00420 return -1;
00421 }
|
|
|
Implements FileHandler. Definition at line 384 of file filehandler.cc. References GetFileSize(), and numBlocks. 00385 {
00386 return GetFileSize() / ( 480 * numBlocks );
00387 }
|
|
|
Implements FileHandler. Definition at line 390 of file filehandler.cc. References fd, FileHandler::filename, and numBlocks. 00391 {
00392 unsigned char data[ 4 ];
00393 assert( fd == -1 );
00394 fd = open( s, O_RDONLY | O_NONBLOCK );
00395 if ( fd < 0 )
00396 return false;
00397 if ( read( fd, data, 4 ) < 0 )
00398 return false;
00399 lseek( fd, 0, SEEK_SET );
00400 numBlocks = ( ( data[ 3 ] & 0x80 ) == 0 ) ? 250 : 300;
00401 filename = s;
00402 return true;
00403
00404 }
|
|
|
Implements FileHandler. Definition at line 359 of file filehandler.cc. References Frame::data, fd, and Frame::GetFrameSize(). 00360 {
00361 int result = write( fd, frame.data, frame.GetFrameSize() );
00362 return result;
00363 }
|
|
|
Definition at line 122 of file filehandler.h. Referenced by Close(), Create(), FileIsOpen(), GetFileSize(), GetFrame(), Open(), and Write(). |
|
|
Definition at line 136 of file filehandler.h. Referenced by GetFrame(), GetTotalFrames(), and Open(). |
1.4.2