From 2d5a938ad21f02f5d44a7d59f5a57d1b66f461e3 Mon Sep 17 00:00:00 2001 From: suter Date: Fri, 11 Apr 2014 10:10:45 +0200 Subject: [PATCH] correct seek's semantic --- src/surf/workstation_interface.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/surf/workstation_interface.cpp b/src/surf/workstation_interface.cpp index f37bff3ae6..4dd66367dc 100644 --- a/src/surf/workstation_interface.cpp +++ b/src/surf/workstation_interface.cpp @@ -315,22 +315,20 @@ sg_size_t Workstation::fileTell(surf_file_t fd){ return fd->current_position; } -int Workstation::fileSeek(surf_file_t fd, sg_size_t offset, int origin){ +msg_error_t Workstation::fileSeek(surf_file_t fd, sg_size_t offset, int origin){ switch (origin) { case SEEK_SET: - fd->current_position = 0; - return MSG_OK; + fd->current_position = offset; + return MSG_OK; case SEEK_CUR: - if(offset > fd->size) - offset = fd->size; - fd->current_position = offset; - return MSG_OK; + fd->current_position += offset; + return MSG_OK; case SEEK_END: - fd->current_position = fd->size; - return MSG_OK; + fd->current_position = fd->size + offset; + return MSG_OK; default: - return MSG_TASK_CANCELED; + return MSG_TASK_CANCELED; } } -- 2.20.1