X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Ffile.cpp;h=0f5652ad9484cf460a2e266f666470c00b67dd02;hp=1b207a25971f960ef99fa5f4481a0be23239e38d;hb=a56e05106571f28dc3044296849ccd5127d7d859;hpb=6c40658510b68788fd5ef0488b20873b6aa32938 diff --git a/source/io/file.cpp b/source/io/file.cpp index 1b207a2..0f5652a 100644 --- a/source/io/file.cpp +++ b/source/io/file.cpp @@ -156,43 +156,22 @@ void File::sync() #endif } -unsigned File::seek(int off, SeekType st) +SeekOffset File::seek(SeekOffset off, SeekType type) { check_access(M_NONE); signal_flush_required.emit(); - - int type = sys_seek_type(st); -#ifdef WIN32 - DWORD ret = SetFilePointer(*handle, off, 0, type); - if(ret==INVALID_SET_FILE_POINTER) - throw system_error("SetFilePointer"); -#else - off_t ret = lseek(*handle, off, type); - if(ret==(off_t)-1) - throw system_error("lseek"); -#endif - + off = sys_seek(handle, off, type); eof_flag = false; - return ret; + return off; } -unsigned File::tell() const +SeekOffset File::tell() const { check_access(M_NONE); -#ifdef WIN32 - DWORD ret = SetFilePointer(*handle, 0, 0, FILE_CURRENT); - if(ret==INVALID_SET_FILE_POINTER) - throw system_error("SetFilePointer"); -#else - off_t ret = lseek(*handle, 0, SEEK_CUR); - if(ret==(off_t)-1) - throw system_error("lseek"); -#endif - - return ret; + return sys_seek(const_cast(handle), 0, S_CUR); } void File::check_access(Mode m) const