예제 #1
0
static bool ChangeTmpToOutFile( FILE *tmpfile, const char *out_name )
/*******************************************************************/
{
    RcStatus    status;      /* error while deleting or renaming */
    FILE        *outfile;
    size_t      numread;
    char        *buffer;

    buffer = RESALLOC( BUFFER_SIZE );

    status = RS_OK;
    RESSEEK( tmpfile, 0, SEEK_SET );
    outfile = ResOpenFileRW( out_name );
    while( (numread = RESREAD( tmpfile, buffer, BUFFER_SIZE )) != 0 ) {
        if( numread != BUFFER_SIZE && RESIOERR( tmpfile, numread ) ) {
            status = RS_READ_ERROR;
            break;
        }
        if( RESWRITE( outfile, buffer, numread ) != numread ) {
            status = RS_WRITE_ERROR;
            break;
        }
    }
    ResCloseFile( outfile );

    RESFREE( buffer );
    return( status == RS_OK );

} /* ChangeTmpToOutFile */
예제 #2
0
/*
 * ReadBitmapInfoHeader-
 * NB when an error occurs this func must return without altering errno
 */
static RcStatus ReadBitmapInfoHeader( BitmapInfoHeader * head, WResFileID fid )
/*****************************************************************************/
{
    WResFileSSize   numread;

    numread = RESREAD( fid, head, sizeof(BitmapInfoHeader) );
    if( numread == sizeof( BitmapInfoHeader ) )
        return( RS_OK );
    return( RESIOERR( fid, numread ) ? RS_READ_ERROR : RS_READ_INCMPLT );
}
예제 #3
0
static RcStatus readFontInfo( FILE *fp, FontInfo *info, int *err_code )
/*********************************************************************/
{
    size_t      numread;

    numread = RESREAD( fp, info, sizeof( *info ) );
    if( numread != sizeof( *info ) ) {
        *err_code = errno;
        return( RESIOERR( fp, numread ) ? RS_READ_ERROR : RS_READ_INCMPLT );
    }
    return( RS_OK );
}
예제 #4
0
static RcStatus readFontInfo( WResFileID fid, FontInfo *info, int *err_code )
/***************************************************************************/
{
    WResFileSSize   numread;

    numread = RESREAD( fid, info, sizeof(FontInfo) );
    if( numread != sizeof(FontInfo) ) {
        *err_code = errno;
        return( RESIOERR( fid, numread ) ? RS_READ_ERROR : RS_READ_INCMPLT );
    }
    return( RS_OK );
}
예제 #5
0
static RcStatus readBitmapFileHeader( WResFileID fid, BitmapFileHeader *head, int *err_code )
/*******************************************************************************************/
{
    WResFileSSize   numread;

    numread = RESREAD( fid, head, sizeof(BitmapFileHeader) );
    if( numread != sizeof( BitmapFileHeader ) ) {
        *err_code = errno;
        return( RESIOERR( fid, numread ) ? RS_READ_ERROR : RS_READ_INCMPLT );
    }
    return( RS_OK );
}
예제 #6
0
static RcStatus readCurFileDirEntry( CurFileDirEntry * entry, WResFileID fid, int *err_code )
/*******************************************************************************************/
{
    WResFileSSize   numread;

    numread = RESREAD( fid, entry, sizeof(CurFileDirEntry) );
    if( numread != sizeof(CurFileDirEntry ) ) {
        *err_code = errno;
        return( RESIOERR( fid, numread ) ? RS_READ_ERROR : RS_READ_INCMPLT );
    }
    return( RS_OK );
} /* readCurFileDirEntry */
예제 #7
0
static RcStatus readIcoCurFileDirHeader( IconCurDirHeader * head, WResFileID fid, int *err_code )
/***********************************************************************************************/
{
    WResFileSSize   numread;

    numread = RESREAD( fid, head, sizeof(IconCurDirHeader) );
    if( numread != sizeof( IconCurDirHeader ) ) {
        *err_code = errno;
        return( RESIOERR( fid, numread ) ? RS_READ_ERROR : RS_READ_INCMPLT );
    }
    return( RS_OK );
} /* readIcoCurFileDirHeader */
예제 #8
0
RcStatus SemCopyDataUntilEOF( WResFileOffset offset, WResFileID fid,
                         void *buff, unsigned buffsize, int *err_code )
/*********************************************************************/
{
    WResFileSSize   numread;

    if( RESSEEK( fid, offset, SEEK_SET ) == -1 ) {
        *err_code = errno;
        return( RS_READ_ERROR );
    }

    while( (numread = RESREAD( fid, buff, buffsize )) != 0 ) {
        if( RESIOERR( fid, numread ) ) {
            *err_code = errno;
            return( RS_READ_ERROR );
        }
        if( RESWRITE( CurrResFile.fid, buff, numread ) != numread ) {
            *err_code = errno;
            return( RS_WRITE_ERROR );
        }
    }

    return( RS_OK );
}