core/win32/os.c
/* seek the current file position to offset bytes from origin, return true if successful */
seek the current file position to offset bytes from origin, return true if successful
seek the current file position to offset bytes from origin return true if successful
bool
os_seek(file_t f, int64 offset, int origin)
{
    FILE_POSITION_INFORMATION info;
    NTSTATUS res;
    int64 abs_offset = offset;
    switch (origin) {
    case OS_SEEK_SET:
        break;
    case OS_SEEK_CUR:
        {
            int64 cur_pos = os_tell(f);
            ASSERT(cur_pos != -1 && "bad file handle?"); 
            abs_offset += cur_pos;
        }
        break;
    case OS_SEEK_END:
        {
            uint64 file_size = 0;
            bool res = os_get_file_size_by_handle(f, &file_size);
            ASSERT(res && "bad file handle?"); 
            abs_offset += file_size;
        }
        break;
    default:
        ASSERT(false && "os_seek: invalid origin");
        return false;
    }
    info.CurrentByteOffset.QuadPart = abs_offset;
    res = nt_set_file_info(f, &info, sizeof(info), FilePositionInformation);
    return NT_SUCCESS(res);
}
bool os_seek ( file_t f , int64 offset , int origin ) { FILE_POSITION_INFORMATION info ; NTSTATUS res ; int64 abs_offset = offset ; switch ( origin ) { case OS_SEEK_SET : break ; case OS_SEEK_CUR : { int64 cur_pos = os_tell ( f ) ; ASSERT ( cur_pos != -1 && " " ) ; abs_offset += cur_pos ; } break ; case OS_SEEK_END : { uint64 file_size = 0 ; bool res = os_get_file_size_by_handle ( f , & file_size ) ; ASSERT ( res && " " ) ; abs_offset += file_size ; } break ; default : ASSERT ( false && " " ) ; return false ; } info . CurrentByteOffset . QuadPart = abs_offset ; res = nt_set_file_info ( f , & info , sizeof ( info ) , FilePositionInformation ) ; return NT_SUCCESS ( res ) ; }
seek the current file position to offset bytes from origin, return true if successful
seek the current file position to offset bytes from origin return true if successful
/* shouldn't fail */ /* shouldn't fail */ /* can fail if invalid seek (past end of read only file for ex.) */