Changeset 219 in xtideuniversalbios for trunk/Serial_Server/library/FlatImage.h
- Timestamp:
- Jan 25, 2012, 7:04:43 AM (13 years ago)
- google:author:
- gregli@hotmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Serial_Server/library/FlatImage.h
r217 r219 6 6 // 7 7 8 #include <stdio.h>9 8 #include "library.h" 10 9 … … 12 11 { 13 12 private: 14 FILE *fp;13 class FileAccess fp; 15 14 16 15 public: 17 FlatImage( char *name, int p_readOnly, int p_drive, int create, unsigned long cyl, unsigned long head, unsigned long sect, int useCHS ); 18 ~FlatImage(); 16 FlatImage( char *name, int p_readOnly, int p_drive, int p_create, unsigned long p_cyl, unsigned long p_head, unsigned long p_sect, int p_useCHS ) : Image( name, p_readOnly, p_drive, p_create, p_cyl, p_head, p_sect, p_useCHS ) 17 { 18 long filesize; 19 19 20 int seekSector( unsigned long cyl, unsigned long sect, unsigned long head ); 21 int seekSector( unsigned long lba ); 22 int writeSector( void *buff ); 23 int readSector( void *buff ); 20 if( p_create ) 21 { 22 char buff[512]; 23 unsigned long size; 24 double sizef; 25 FileAccess cf; 26 27 size = (unsigned long) p_cyl * (unsigned long) p_sect * (unsigned long) p_head; 28 if( size > cf.MaxSectors ) 29 log( -1, "'%s', can't create flat file with size greater than %lu 512-byte sectors", name, cf.MaxSectors ); 30 sizef = size / 2048.0; // 512 byte sectors -> MB 31 32 cf.Create( name ); 33 34 memset( &buff[0], 0, 512 ); 35 while( size-- ) 36 cf.Write( &buff[0], 512 ); 37 38 if( p_cyl > 1024 ) 39 log( 0, "Created file '%s', size %.1lf MB", name, sizef ); 40 else 41 log( 0, "Created file '%s', geometry %u:%u:%u, size %.1lf MB", name, p_cyl, p_sect, p_head, sizef ); 42 43 cf.Close(); 44 } 45 46 fp.Open( name ); 47 48 totallba = fp.SizeSectors(); 49 50 init( name, p_readOnly, p_drive, p_cyl, p_head, p_sect, p_useCHS ); 51 } 52 53 FlatImage::~FlatImage() 54 { 55 fp.Close(); 56 } 57 58 void seekSector( unsigned long lba ) 59 { 60 fp.SeekSectors( lba ); 61 } 62 63 void writeSector( void *buff ) 64 { 65 fp.Write( buff, 512 ); 66 } 67 68 void readSector( void *buff ) 69 { 70 fp.Read( buff, 512 ); 71 } 24 72 }; 25 73
Note:
See TracChangeset
for help on using the changeset viewer.