コード例 #1
0
ファイル: gm_res.c プロジェクト: mrtos/gk6105s-id
/**
*******************************************************************************
**
** Open a new resource
**
*******************************************************************************
*/
GM_RES_S* GM_RES_Open( char* filename )
{
    GM_RES_S*     resource = 0;
    GM_RES_TYPE_E type = GM_RES_TYPE_UNKNOWN;
    GFS_S*        gfs = 0;
    S8            xref = -1;
    int           index;
    
    gfs = GFS_Open( filename, "r" );
    if( !gfs )
    {
        return( 0 );
    }
        
    type = RES_GetTypeOfFile( gfs );
    if( type == GM_RES_CLASS_UNKNOWN )
    {
        GFS_Close( gfs );
        return( 0 );
    }
    
    xref = RES_GetFuncXrefIndex( type );
    if( xref == -1 )
    {
        GFS_Close( gfs );
        return( 0 );
    }
    
    resource = (GM_RES_S*)RTOS_MemoryAllocate( (RTOS_Size)sizeof(GM_RES_S), GTRUE );
    if( !resource )
    {
        GFS_Close( gfs );
        return( 0 );
    }
    RTOS_MemorySet( (RTOS_Memory)resource, 0, (RTOS_Size)sizeof(GM_RES_S) );
    
    resource->type = type;
    resource->gfs = gfs;
    resource->xref = xref;
    RTOS_MemorySet( (RTOS_Memory)(resource->name), 0, GM_RES_NAME_LENGTH_MAX );
    for( index=0; index < GM_RES_NAME_LENGTH_MAX; index++ )
    {
        resource->name[index] = filename[index];
        if( filename[index] == '\0' )
            break;
    }
    
    if( ! res_func_xref[xref].open( resource ) )
    {
        GFS_Close( gfs );
        RTOS_MemoryRelease( (RTOS_Memory)resource );
        return( 0 );
    }
    
    return( resource ); 
}
コード例 #2
0
//--------------------------------------------------------------------------------------------------------------------------------------
Sint32 GetFileSize(int file_id)
{
#ifndef ACTION_REPLAY	
	GfsHn gfs;
    Sint32 sctsize, nsct, lastsize;
    
    gfs = GFS_Open(file_id);
    GFS_GetFileSize(gfs, &sctsize, &nsct, &lastsize);

    GFS_Close(gfs);
//	return sctsize*nsct;
	return (sctsize*(nsct-1) + lastsize);
#else
    return 300;
#endif	
}