コード例 #1
0
bool WRLoadResourceFrom_RC( WRInfo *info )
{
    WResTargetOS        target_os;
    WRFileType          target;
    char                fn_path[_MAX_PATH];
    bool                is_wres;
    bool                ok;

    ok = (info != NULL && info->file_name != NULL);

    if( ok ) {
        WRGetInternalRESName( info->file_name, fn_path );
    }

#ifndef __NT__
    if( ok ) {
        target = WRIdentifyFile( fn_path );
        ok = !WRIs32Bit( target );
        if( !ok ) {
            WRDisplayErrorMsg( WR_NOLOAD32IN16 );
        }
    }
#endif

    if( ok ) {
        ok = loadResDirFromRES( info, fn_path, &is_wres );
    }

    if( ok ) {
        target_os = WResGetTargetOS( info->dir );
        target = WR_INVALID_FILE;
        switch( target_os ) {
        case WRES_OS_WIN16:
            target = WR_WIN16M_RES;
            if( is_wres ) {
                target = WR_WIN16W_RES;
            }
            break;
        case WRES_OS_WIN32:
            target = WR_WINNTM_RES;
            if( is_wres ) {
                target = WR_WINNTW_RES;
            }
            break;
        }
        info->internal_type = target;
        if( target == WR_INVALID_FILE ) {
            WRDisplayErrorMsg( WR_INVALIDFILE );
            ok = false;
        }
    }

    if( ok ) {
        info->internal_filename = WRStrDup( fn_path );
        ok = (info->internal_filename != NULL);
    }

    return( ok );
}
コード例 #2
0
ファイル: wreres.c プロジェクト: Ukusbobra/open-watcom-v2
WREResInfo *WRELoadResource( const char *file_name )
{
    WRFileType  file_type;
    WREResInfo  *res_info;
    Bool        ok;

    WRESetWaitCursor( TRUE );

    ok = ((res_info = WREAllocResInfo()) != NULL);

    if( ok ) {
        file_type = WRIdentifyFile( file_name );
        ok = (file_type != WR_INVALID_FILE);
    }

    if( ok ) {
        res_info->info = WRLoadResource( file_name, file_type );
        ok = (res_info->info != NULL);
    }

    if( ok ) {
        file_type = res_info->info->file_type;
        if( res_info->info->internal_type != WR_DONT_KNOW ) {
            file_type = res_info->info->internal_type;
        }
        res_info->is32bit = WRIs32Bit( file_type );
    }

    if( ok ) {
        res_info->symbol_table = WRInitHashTable();
        ok = (res_info->symbol_table != NULL);
    }

    if( !ok ) {
        if( res_info != NULL ) {
            WREFreeResInfo( res_info );
            res_info = NULL;
        }
    }

    WRESetWaitCursor( FALSE );

    return( res_info );
}
コード例 #3
0
static bool WRSaveResourceToWRES( WRInfo *info, WResFileID src_fid, WResFileID dst_fid )
{
    WResDir     new_dir;
    WRFileType  save_type;
    bool        is32bit;
    bool        ok;

    ok = ((new_dir = WResInitDir()) != NULL);

    if( ok ) {
        save_type = info->save_type;
        if( save_type != WR_WIN16M_RES && save_type != WR_WIN16W_RES &&
            save_type != WR_WINNTM_RES && save_type != WR_WINNTW_RES ) {
            if( info->internal_type != WR_DONT_KNOW ) {
                save_type = info->internal_type;
            }
        }
        is32bit = WRIs32Bit( save_type );
        if( is32bit ) {
            new_dir->TargetOS = WRES_OS_WIN32;
        }
    }

    if( ok ) {
        ok = WRWriteResourcesToWRES( info, new_dir, src_fid, dst_fid, is32bit );
    }

    if( ok ) {
        ok = !WResWriteDir( dst_fid, new_dir );
    }

    if( new_dir != NULL ) {
        WResFreeDir( new_dir );
    }

    return( ok );
}
コード例 #4
0
static bool saveResourceToRES( WRInfo *info, bool backup, const char *save_name, const char *file_name )
{
    WResFileID  src_fid;
    WResFileID  dst_fid;
    bool        is_wres;
    bool        ok;
    bool        use_rename;
    WRFileType  save_type;

    src_fid = WRES_NIL_HANDLE;
    dst_fid = WRES_NIL_HANDLE;

    ok = true;

    if( ok ) {
        save_type = info->save_type;
        if( save_type != WR_WIN16M_RES && save_type != WR_WIN16W_RES &&
            save_type != WR_WINNTM_RES && save_type != WR_WINNTW_RES ) {
            if( info->internal_type != WR_DONT_KNOW ) {
                save_type = info->internal_type;
            }
        }
#ifndef __NT__
        ok = !WRIs32Bit( save_type );
        if( !ok ) {
            WRDisplayErrorMsg( WR_NOSAVE32IN16 );
        }
#endif
    }

    if( ok ) {
        if( backup && WRFileExists( save_name ) ) {
            use_rename = (file_name != NULL && stricmp( file_name, save_name ));
            ok = WRBackupFile( save_name, use_rename );
        }
    }

    if( ok ) {
        if( file_name != NULL ) {
            ok = ((src_fid = ResOpenFileRO( info->tmp_file )) != WRES_NIL_HANDLE);
        }
    }

    is_wres = (save_type == WR_WIN16W_RES || save_type == WR_WINNTW_RES);

    if( ok ) {
        ok = ((dst_fid = ResOpenNewFile( save_name )) != WRES_NIL_HANDLE);
        if( ok && is_wres ) {
            ok = !WResFileInit( dst_fid );
        }
    }

    if( ok ) {
        if( is_wres ) {
            ok = WRSaveResourceToWRES( info, src_fid, dst_fid );
        } else {
            ok = WRSaveResourceToMRES( info, src_fid, dst_fid );
        }
    }

    if( src_fid != WRES_NIL_HANDLE ) {
        ResCloseFile( src_fid );
    }

    if( dst_fid != WRES_NIL_HANDLE ) {
        ResCloseFile( dst_fid );
    }

    if( !ok ) {
        if( dst_fid != WRES_NIL_HANDLE ) {
            WRDeleteFile( save_name );
        }
    }

    return( ok );
}
コード例 #5
0
bool WdeOpenResource( char *fn )
{
    char                *name;
    WdeResInfo          *res_info;
    WdeGetFileStruct    gf;
    bool                ok, got_name;

    WdeSetWaitCursor( TRUE );

    res_info = NULL;
    name = NULL;
    got_name = FALSE;

    if( fn != NULL ) {
        if( WdeFileExists( fn ) ) {
            name = WdeStrDup( fn );
            gf.fn_offset = WRFindFnOffset( name );
        } else {
            return( FALSE );
        }
    } else {
        gf.file_name = NULL;
        gf.title = WdeResOpenTitle;
        gf.filter = WdeResOpenFilter;
        ok = ((name = WdeGetOpenFileName( &gf )) != NULL);
    }

    if( ok ) {
        got_name = TRUE;
        ok = ((res_info = WdeLoadResource( name )) != NULL);
    }

    if( ok ) {
        res_info->hash_table = WRInitHashTable();
        ok = (res_info->hash_table != NULL);
    }

    if( ok ) {
        if( res_info->info->internal_type != WR_DONT_KNOW ) {
            res_info->is32bit = WRIs32Bit( res_info->info->internal_type );
        } else {
            res_info->is32bit = WRIs32Bit( res_info->info->file_type );
        }
        ok = WdeAddDlgItems( res_info );
    }

    if( ok ) {
        WdeFindAndLoadSymbols( res_info );
        ok = WdeCreateResourceWindow( res_info, gf.fn_offset, NULL );
    }

    if( ok ) {
        if( WdeResInfoHasDialogs( res_info ) ) {
            WdeSelectDialog( res_info );
        } else {
            WdeDisplayErrorMsg( WDE_PRJHASNODIALOGS );
        }
        ListAddElt( &WdeResList, (void *)res_info );
        WdeSetResModified( res_info, FALSE );
        WdeCheckBaseScrollbars( FALSE );
    }

    if( !ok ) {
        if( res_info != NULL ) {
            WdeFreeResInfo( res_info );
            res_info = NULL;
        }
        if( got_name ) {
            WdeDisplayErrorMsg( WDE_RESOURCESNOTLOADED );
        }
    }

    if( name != NULL ) {
        WRMemFree( name );
    }

    WdeSetWaitCursor( FALSE );

    return( ok );
}