Changeset 225 in xtideuniversalbios for trunk/Serial_Server/win32


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/win32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Serial_Server/win32/Win32.cpp

    r219 r225  
    2626        "",
    2727        "  -g [cyl:head:sect]  Geometry in cylinders, sectors per cylinder, and heads",
    28         "                      -g without parameters uses CHS mode (default is LBA28)",
     28        "                      -g also implies CHS addressing mode (default is LBA28)",
    2929        "",
    3030        "  -n [megabytes]      Create new disk with given size or use -g geometry",
     
    161161        else if( imagecount < 2 )
    162162        {
     163            if( createFile && cyl == 0 )
     164            {
     165                cyl = 65;
     166                sect = 63;
     167                head = 16;
     168            }
    163169            images[imagecount] = new FlatImage( argv[t], readOnly, imagecount, createFile, cyl, head, sect, useCHS );
    164170            imagecount++;
  • trunk/Serial_Server/win32/Win32File.h

    r219 r225  
    1818{
    1919public:
    20     void Create( char *p_name )
     20    int Create( char *p_name )
    2121    {
    2222        fp = CreateFileA( p_name, GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
    23         if( !fp )
    24             log( -1, "'%s', could not create file", p_name );
     23
     24        if( fp == INVALID_HANDLE_VALUE )
     25        {
     26            if( GetLastError() == ERROR_FILE_EXISTS )
     27            {
     28                log( 0, "'%s', file already exists", p_name );
     29                return( 0 );
     30            }
     31            else
     32                log( -1, "'%s', could not create file", p_name );
     33        }
     34
    2535        name = p_name;
     36
     37        return( 1 );
    2638    }
    2739
     
    2941    {
    3042        fp = CreateFileA( p_name, GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
    31         if( !fp )
     43
     44        if( fp == INVALID_HANDLE_VALUE )
    3245            log( -1, "'%s', could not open file", p_name );
     46
    3347        name = p_name;
    3448    }
     
    7892
    7993        if( !ReadFile( fp, buff, len, &out_len, NULL ) || len != out_len )
    80             log( -1, "'%s', ReadFile failed" );
     94            log( -1, "'%s', ReadFile failed", name );
    8195    }
    8296
     
    86100
    87101        if( !WriteFile( fp, buff, len, &out_len, NULL ) || len != out_len )
    88             log( -1, "'%s', WriteFile failed" );
     102            log( -1, "'%s', WriteFile failed", name );
    89103    }
    90104
  • trunk/Serial_Server/win32/Win32Serial.h

    r219 r225  
    4040       
    4141            pipe = CreateNamedPipeA( PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE|PIPE_REJECT_REMOTE_CLIENTS, 2, 1024, 1024, 0, NULL );
    42             if( !pipe )
     42            if( pipe == INVALID_HANDLE_VALUE )
    4343                log( -1, "Could not CreateNamedPipe " PIPENAME );
    4444       
     
    6262           
    6363                pipe = CreateFileA( name, GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
    64                 if( !pipe )
     64                if( pipe == INVALID_HANDLE_VALUE )
    6565                    log( -1, "Could not Open \"%s\"", name );
    6666           
Note: See TracChangeset for help on using the changeset viewer.