示例#1
0
def obj_close(context):
    fileobj = ffi.from_handle(context.hidden.unknown.data1)
    retval = 0
    if hasattr(fileobj, 'close'):
        if fileobj.close():
            retval = -1
    sdl.SDL_FreeRW(context)
    return retval
示例#2
0
def obj_close(context):
    fileobj = ffi.from_handle(context.hidden.unknown.data1)
    retval = 0
    if hasattr(fileobj, 'close'):
        if fileobj.close():
            retval = -1
    sdl.SDL_FreeRW(context)
    return retval
示例#3
0
def obj_seek(context, offset, whence):
    fileobj = ffi.from_handle(context.hidden.unknown.data1)
    if not hasattr(fileobj, 'tell') or not hasattr(fileobj, 'seek'):
        return -1
    # whence = 1 => SEEK_CUR, from python docs
    if offset != 0 or whence != 1:
        # We're actually being called to do a seek
        fileobj.seek(offset, whence)
    return fileobj.tell()
示例#4
0
def obj_seek(context, offset, whence):
    fileobj = ffi.from_handle(context.hidden.unknown.data1)
    if not hasattr(fileobj, 'tell') or not hasattr(fileobj, 'seek'):
        return -1
    # whence = 1 => SEEK_CUR, from python docs
    if offset != 0 or whence != 1:
        # We're actually being called to do a seek
        fileobj.seek(offset, whence)
    return fileobj.tell()
示例#5
0
def obj_write(context, input, size, maxnum):
    fileobj = ffi.from_handle(context.hidden.unknown.data1)
    if not hasattr(fileobj, 'write'):
        return -1
    data = ffi.buffer(input, size * maxnum)
    try:
        fileobj.write(data)
    except IOError:
        return -1
    return size * maxnum
示例#6
0
def obj_write(context, input, size, maxnum):
    fileobj = ffi.from_handle(context.hidden.unknown.data1)
    if not hasattr(fileobj, 'write'):
        return -1
    data = ffi.buffer(input, size*maxnum)
    try:
        fileobj.write(data)
    except IOError:
        return -1
    return size*maxnum
示例#7
0
def obj_read(context, output, size, maxnum):
    fileobj = ffi.from_handle(context.hidden.unknown.data1)
    if not hasattr(fileobj, 'read'):
        return -1
    data = fileobj.read(size * maxnum)
    if not data:
        return -1
    retval = len(data)
    ffi.memmove(output, data, retval)
    retval = retval // size
    return retval
示例#8
0
def obj_read(context, output, size, maxnum):
    fileobj = ffi.from_handle(context.hidden.unknown.data1)
    if not hasattr(fileobj, 'read'):
        return -1
    data = fileobj.read(size * maxnum)
    if not data:
        return -1
    retval = len(data)
    ffi.memmove(output, data, retval)
    retval = retval // size
    return retval