示例#1
0
static wio_off_t res_seek( WResFileID handle, wio_off_t position, int where )
/***************************************************************************/
/* Workaround wres bug */
{
    if( ( where == SEEK_SET ) && ( handle == hInstance.handle ) ) {
        return( QLSeek( handle, position + FileShift, where, NULL ) - FileShift );
    } else {
        return( QLSeek( handle, position, where, NULL ) );
    }
}
示例#2
0
文件: linkutil.c 项目: JWasm/JWlink
//extern int WLinkItself;
static off_t ResSeek( int handle, off_t position, int where )
/***********************************************************/
/* Workaround wres bug */
{
    if( ( where == SEEK_SET ) && ( handle == WLinkItself ) ) {
        return( QLSeek( handle, position + FileShift, where, NULL ) - FileShift );
    } else {
        return( QLSeek( handle, position, where, NULL ) );
    }
}
示例#3
0
bool CacheOpen( file_list *list )
/**************************************/
{
    infilelist  *file;
    unsigned    numblocks;
    char        **cache;

    if( list == NULL )
        return( TRUE );
    file = list->file;
    if( file->flags & INSTAT_IOERR )
        return( FALSE );
    if( DoObjOpen( file ) ) {
        file->flags |= INSTAT_IN_USE;
    } else {
        file->flags |= INSTAT_IOERR;
        return( FALSE );
    }
    if( file->len == 0 ) {
        file->len = QFileSize( file->handle );
        if( file->len == 0 ) {
            LnkMsg( ERR+MSG_BAD_OBJECT, "s", file->name );
            file->flags |= INSTAT_IOERR;
            return( FALSE );
        }
    }
    if( !(file->flags & INSTAT_SET_CACHE) ) {
        if( LinkFlags & CACHE_FLAG ) {
            file->flags |= INSTAT_FULL_CACHE;
        } else if( LinkFlags & NOCACHE_FLAG ) {
            file->flags |= INSTAT_PAGE_CACHE;
        } else {
            if( file->flags & INSTAT_LIBRARY ) {
                file->flags |= INSTAT_PAGE_CACHE;
            } else {
                file->flags |= INSTAT_FULL_CACHE;
            }
        }
    }
    if( file->cache == NULL ) {
        if( file->flags & INSTAT_FULL_CACHE ) {
            _ChkAlloc( file->cache, file->len );
            if( file->currpos != 0 ) {
                QLSeek( file->handle, 0, SEEK_SET, file->name );
            }
            QRead( file->handle, file->cache, file->len, file->name );
            file->currpos = file->len;
        } else {
            numblocks = NumCacheBlocks( file->len );
            _Pass1Alloc( file->cache, numblocks * sizeof( char * ) );
            cache = file->cache;
            while( numblocks > 0 ) {
                *cache = NULL;
                cache++;
                numblocks--;
            }
        }
    }
    return( TRUE );
}
示例#4
0
WResFileOffset res_seek( WResFileID fid, WResFileOffset amount, int where )
{
    if( fid == hInstance.fid ) {
        if( where == SEEK_SET ) {
            return( lseek( WRES_FID2PH( fid ), amount + WResFileShift, where ) - WResFileShift );
        } else {
            return( lseek( WRES_FID2PH( fid ), amount, where ) );
        }
    }

    DbgAssert( where != SEEK_END );
    DbgAssert( !(where == SEEK_CUR && amount < 0) );

    if( WRES_FID2PH( fid ) == Root->outfile->handle ) {
        if( where == SEEK_CUR ) {
            unsigned long   old_pos;
            unsigned long   new_pos;

            old_pos = PosLoad();
            new_pos = old_pos + amount;
            if( new_pos > old_pos ) {
                PadLoad( (size_t)amount );
            } else {
                SeekLoad( new_pos );
            }
            return( new_pos );
        } else {
            SeekLoad( amount );
            return( amount );
        }
    } else {
        return( QLSeek( WRES_FID2PH( fid ), amount, where, "resource file" ) );
    }
}
示例#5
0
void QSeek( f_handle file, wio_off_t position, char *name )
/***********************************************************/
{
    QLSeek( file, position, SEEK_SET, name );
}
示例#6
0
文件: linkio.c 项目: JWasm/JWlink
void QSeek( f_handle file, long position, char *name )
/***********************************************************/
{
    QLSeek( file, position, TIO_SEEK_START, name );
}
示例#7
0
void QSeek( f_handle file, unsigned long position, char *name )
/*************************************************************/
{
    QLSeek( file, position, SEEK_SET, name );
}