]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/internal/io/BamHttp_p.cpp
Added generic I/O device to BamIndex side of things
[bamtools.git] / src / api / internal / io / BamHttp_p.cpp
index d889db46520fd1789fa2d31b1e55a611d2e30870..30d2c145cbee469bfa9dbab933a5206469361bd7 100644 (file)
@@ -333,7 +333,7 @@ bool BamHttp::ReceiveResponse(void) {
     return false;
 }
 
-bool BamHttp::Seek(const int64_t& position) {
+bool BamHttp::Seek(const int64_t& position, const int origin) {
 
     // if HTTP device not in a valid state
     if ( !IsOpen() ) {
@@ -343,8 +343,16 @@ bool BamHttp::Seek(const int64_t& position) {
 
     // discard socket's buffer contents, update positions, & return success
     m_socket->ClearBuffer();
-    m_filePosition = position;
-    m_endRangeFilePosition = position;
+
+    if ( origin == SEEK_CUR )
+        m_filePosition += position;
+    else if ( origin == SEEK_SET )
+        m_filePosition = position;
+    else {
+        // TODO: set error string
+        return false;
+    }
+    m_endRangeFilePosition = m_filePosition;
     return true;
 }