]> git.tdb.fi Git - libs/core.git/blobdiff - source/io/seekable.cpp
Move most platform-specific code into overlay directories
[libs/core.git] / source / io / seekable.cpp
index 35ab5a05104fef55fbe625a3e55cdff2d1b18590..6bc84855541c6f0974eb3c8ba29405fb67d8febd 100644 (file)
@@ -1,46 +1,8 @@
-#ifndef WIN32
-#define _LARGEFILE64_SOURCE
-#include <cerrno>
-#include <unistd.h>
-#else
-#include <windows.h>
-#endif
-#include <msp/core/systemerror.h>
 #include <msp/strings/format.h>
-#include "handle.h"
-#include "handle_private.h"
 #include "seekable.h"
 
 using namespace std;
 
-namespace {
-
-using namespace Msp::IO;
-
-int sys_seek_type(SeekType st)
-{
-#ifdef WIN32
-       if(st==S_BEG)
-               return FILE_BEGIN;
-       else if(st==S_CUR)
-               return FILE_CURRENT;
-       else if(st==S_END)
-               return FILE_END;
-#else
-       if(st==S_BEG)
-               return SEEK_SET;
-       else if(st==S_CUR)
-               return SEEK_CUR;
-       else if(st==S_END)
-               return SEEK_END;
-#endif
-
-       throw invalid_argument("sys_seek_type");
-}
-
-} // namespace
-
-
 namespace Msp {
 namespace IO {
 
@@ -51,33 +13,5 @@ bad_seek::bad_seek(SeekOffset offset, SeekType type):
                format("SeekType(%d)", type))
 { }
 
-
-SeekOffset sys_seek(Handle &handle, SeekOffset offset, SeekType type)
-{
-#ifdef WIN32
-       LONG high = offset>>32;
-       DWORD ret = SetFilePointer(*handle, offset, &high, sys_seek_type(type));
-       if(ret==INVALID_SET_FILE_POINTER)
-       {
-               DWORD err = GetLastError();
-               if(err!=NO_ERROR)
-                       throw system_error("SetFilePointer");
-       }
-
-       return (SeekOffset(high)<<32) | ret;
-#else
-       off64_t ret = lseek64(*handle, offset, sys_seek_type(type));
-       if(ret==(off64_t)-1)
-       {
-               if(errno==EINVAL)
-                       throw bad_seek(offset, type);
-               else
-                       throw system_error("lseek64");
-       }
-
-       return ret;
-#endif
-}
-
 } // namespace IO
 } // namespace Msp