Changeset 225 in xtideuniversalbios for trunk/Serial_Server/library


Ignore:
Timestamp:
Jan 27, 2012, 6:19:21 PM (13 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

Serial Server, minor improvements to file handling.

Location:
trunk/Serial_Server/library
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Serial_Server/library/File.h

    r219 r225  
    1818{
    1919public:
    20     void Create( char *p_name )
     20    int Create( char *p_name )
    2121    {
    2222        fp = fopen( p_name, "r" );
    2323
    2424        if( fp )
    25             log( -1, "Create Failure: '%s' already exists", p_name );
     25        {
     26            log( 0, "'%s' file already exists", p_name );
     27            fclose( fp );
     28            return( 0 );
     29        }
    2630       
    2731        if( !(fp = fopen( p_name, "w" )) )
     
    2933
    3034        name = p_name;
     35       
     36        return( 1 );
    3137    }
    3238
  • trunk/Serial_Server/library/FlatImage.h

    r219 r225  
    3030            sizef = size / 2048.0;   // 512 byte sectors -> MB
    3131
    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();
     32            if( 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                cf.Close();
     43            }
    4444        }
    4545
Note: See TracChangeset for help on using the changeset viewer.