]> git.donarmstrong.com Git - samtools.git/commitdiff
A bug fix, "samtools view" is now working again.
authorPetr Danecek <pd3@sanger.ac.uk>
Wed, 16 Sep 2009 11:05:41 +0000 (11:05 +0000)
committerPetr Danecek <pd3@sanger.ac.uk>
Wed, 16 Sep 2009 11:05:41 +0000 (11:05 +0000)
knetfile.c
razf.c

index ac51a6bf39b4e702bbe24cc4afdb118bf5524911..9e11dcc19ed71d42bab4ae47f480b81382602fc9 100644 (file)
@@ -503,7 +503,7 @@ off_t knet_seek(knetFile *fp, off_t off, int whence)
                        return -1;
                }
                fp->offset = offset;
-               return fp->offset;
+               return 0;
        }
     else if (fp->type == KNF_TYPE_FTP) 
     {
@@ -514,12 +514,12 @@ off_t knet_seek(knetFile *fp, off_t off, int whence)
         else if ( whence==SEEK_END)
             fp->offset = fp->file_size+off;
                fp->is_ready = 0;
-               return fp->offset;
+               return 0;
        } 
     else if (fp->type == KNF_TYPE_HTTP) 
     {
-               if (whence == SEEK_END) { // FIXME: we can surely allow SEEK_CUR and SEEK_END in future
-                       fprintf(stderr, "[knet_seek] SEEK_END is supported for HTTP. Offset is unchanged.\n");
+               if (whence == SEEK_END) { // FIXME: can we allow SEEK_END in future?
+                       fprintf(stderr, "[knet_seek] SEEK_END is not supported for HTTP. Offset is unchanged.\n");
                        return -1;
                }
         if (whence==SEEK_CUR)
diff --git a/razf.c b/razf.c
index ce8edb886797033a434423d68046fea9928ae481..9b9267e494fe95cddde5e1e31c50cfc958701a11 100644 (file)
--- a/razf.c
+++ b/razf.c
@@ -536,8 +536,10 @@ int razf_get_data_size(RAZF *rz, int64_t *u_size, int64_t *c_size){
                case FILE_TYPE_PLAIN:
                        if(rz->end == 0x7fffffffffffffffLL){
 #ifdef _USE_KNETFILE
-                               if((n = knet_seek(rz->x.fpr, 0, SEEK_CUR)) == -1) return 0;
-                               rz->end = knet_seek(rz->x.fpr, 0, SEEK_END);
+                               if(knet_seek(rz->x.fpr, 0, SEEK_CUR) == -1) return 0;
+                n = knet_tell(rz->x.fpr);
+                               knet_seek(rz->x.fpr, 0, SEEK_END);
+                rz->end = knet_tell(rz->x.fpr);
                                knet_seek(rz->x.fpr, n, SEEK_SET);
 #else
                                if((n = lseek(rz->filedes, 0, SEEK_CUR)) == -1) return 0;
@@ -715,7 +717,8 @@ int64_t razf_jump(RAZF *rz, int64_t block_start, int block_offset){
                rz->buf_off = rz->buf_len = 0;
                pos = block_start + block_offset;
 #ifdef _USE_KNETFILE
-               pos = knet_seek(rz->x.fpr, pos, SEEK_SET);
+               knet_seek(rz->x.fpr, pos, SEEK_SET);
+        pos = knet_tell(rz->x.fpr);
 #else
                pos = lseek(rz->filedes, pos, SEEK_SET);
 #endif
@@ -741,7 +744,8 @@ int64_t razf_seek(RAZF* rz, int64_t pos, int where){
        else if (where == SEEK_END) pos += rz->src_end;
        if(rz->file_type == FILE_TYPE_PLAIN){
 #ifdef _USE_KNETFILE
-               seek_pos = knet_seek(rz->x.fpr, pos, SEEK_SET);
+               knet_seek(rz->x.fpr, pos, SEEK_SET);
+        seek_pos = knet_tell(rz->x.fpr);
 #else
                seek_pos = lseek(rz->filedes, pos, SEEK_SET);
 #endif