Ejemplo n.º 1
0
WRFileType WR_EXPORT WRIdentifyFile( const char *file )
{
    WRFileType  ftype;
    char        ext[_MAX_EXT];
    int         fh;
    int         ok;

    fh = -1;

    ok = (file != NULL);

    if( ok ) {
        _splitpath( file, NULL, NULL, NULL, ext );
        if( !stricmp( ext, ".bmp" ) ) {
            ftype = WRIdentifyWinBMPFile( file );
        } else if( !stricmp( ext, ".cur" ) ) {
            ftype = WRIdentifyWinICOFile( file );
        } else if( !stricmp( ext, ".ico" ) ) {
            ftype = WRIdentifyWinICOFile( file );
        } else if( !stricmp( ext, ".dlg" ) ) {
            //ftype = WRIdentifyWinRCFile( file );
            ftype = WR_WIN_RC_DLG;
        } else if( !stricmp( ext, ".rc" ) ) {
            ftype = WRIdentifyWinRCFile( file );
        } else if( !stricmp( ext, ".str" ) ) {
            ftype = WR_WIN_RC_STR;
        } else if( !stricmp( ext, ".mnu" ) ) {
            ftype = WR_WIN_RC_MENU;
        } else if( !stricmp( ext, ".acc" ) ) {
            ftype = WR_WIN_RC_ACCEL;
        } else if( !stricmp( ext, ".res" ) ) {
            ftype = WRIdentifyRESFile( file );
        } else if( !stricmp( ext, ".exe" ) ) {
            ok = ((fh = ResOpenFileRO( file )) != -1);
            if( ok ) {
                ftype = WRIdentifyEXEFile( fh, FALSE );
            }
        } else if( !stricmp( ext, ".dll" ) ) {
            ok = ((fh = ResOpenFileRO( file )) != -1);
            if ( ok ) {
                ftype = WRIdentifyEXEFile( fh, TRUE );
            }
        } else {
            ok = FALSE;
        }
    }

    if( fh != -1 ) {
        ResCloseFile( fh );
    }

    if( ok ) {
        return( ftype );
    } else {
        return( WR_INVALID_FILE );
    }
}
Ejemplo n.º 2
0
WRFileType WRAPI WRIdentifyFile( const char *fname )
{
    WRFileType  ftype;
    char        ext[_MAX_EXT];
    bool        ok;

    ok = ( fname != NULL );
    if( ok ) {
        _splitpath( fname, NULL, NULL, NULL, ext );
        if( stricmp( ext, ".bmp" ) == 0 ) {
            ftype = WRIdentifyWinBMPFile( fname );
        } else if( stricmp( ext, ".cur" ) == 0 ) {
            ftype = WRIdentifyWinICOFile( fname );
        } else if( stricmp( ext, ".ico" ) == 0 ) {
            ftype = WRIdentifyWinICOFile( fname );
        } else if( stricmp( ext, ".dlg" ) == 0 ) {
            //ftype = WRIdentifyWinRCFile( fname );
            ftype = WR_WIN_RC_DLG;
        } else if( stricmp( ext, ".rc" ) == 0 ) {
            ftype = WRIdentifyWinRCFile( fname );
        } else if( stricmp( ext, ".str" ) == 0 ) {
            ftype = WR_WIN_RC_STR;
        } else if( stricmp( ext, ".mnu" ) == 0 ) {
            ftype = WR_WIN_RC_MENU;
        } else if( stricmp( ext, ".acc" ) == 0 ) {
            ftype = WR_WIN_RC_ACCEL;
        } else if( stricmp( ext, ".res" ) == 0 ) {
            ftype = WRIdentifyRESFile( fname );
        } else if( stricmp( ext, ".exe" ) == 0 ) {
            ftype = WRIdentifyEXEFile( fname, false );
        } else if( stricmp( ext, ".dll" ) == 0 ) {
            ftype = WRIdentifyEXEFile( fname, true );
        } else {
            ok = false;
        }
    }

    if( ok ) {
        return( ftype );
    } else {
        return( WR_INVALID_FILE );
    }
}