X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=knetfile.c;h=322885a379642d19b638a9b0164b153cdcf5ed0b;hb=3ddb3942053df00fdae714e77cbc2f5618db617e;hp=dbec205d2c29a0a562a5e5d337a3e914c3de7c21;hpb=34c418836df8a03e0eb5243b9240f55abab5bd08;p=samtools.git diff --git a/knetfile.c b/knetfile.c index dbec205..322885a 100644 --- a/knetfile.c +++ b/knetfile.c @@ -208,22 +208,26 @@ off_t knet_read(knetFile *fp, void *buf, off_t len) return l; } -off_t knet_seek(knetFile *fp, off_t off, int whence) +int knet_seek(knetFile *fp, off_t off, int whence) { if (fp->type == KNF_TYPE_LOCAL) { - fp->offset = lseek(fp->fd, off, whence); - return fp->offset; + if (lseek(fp->fd, off, whence) == -1) { + perror("lseek"); + return -1; + } + fp->offset = off; + return 0; } if (fp->type == KNF_TYPE_FTP) { - if (whence != SEEK_SET) { + if (whence != SEEK_SET) { // FIXME: we can surely allow SEEK_CUR and SEEK_END in future fprintf(stderr, "[knet_seek] only SEEK_SET is supported for FTP. Offset is unchanged.\n"); return -1; } if (!fp->no_reconnect) kftp_reconnect(fp); kftp_connect_file(fp, off); - return fp->offset; + return 0; } - return 0; + return -1; } int knet_close(knetFile *fp)