Skip to content

Commit 270e1e5

Browse files
committed
try
1 parent 9254b57 commit 270e1e5

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

src/slow5.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,14 @@ struct slow5_file *slow5_init(FILE *fp, const char *pathname, enum slow5_fmt for
191191

192192
s5p->meta.pathname = pathname;
193193
if ((s5p->meta.start_rec_offset = ftello(fp)) == -1) {
194-
SLOW5_ERROR("Obtaining file offset with ftello() failed: %s.", strerror(errno));
195-
free(fread_buff);
196-
slow5_press_free(s5p->compress);
197-
slow5_hdr_free(header);
198-
free(s5p);
199-
slow5_errno = SLOW5_ERR_IO;
200-
return NULL;
194+
SLOW5_WARNING("Obtaining file offset with ftello() failed: %s. Seeking would not work.", strerror(errno));
195+
// free(fread_buff);
196+
// slow5_press_free(s5p->compress);
197+
// slow5_hdr_free(header);
198+
// free(s5p);
199+
// slow5_errno = SLOW5_ERR_IO;
200+
// return NULL;
201+
// can manually set if required?
201202
}
202203

203204
return s5p;
@@ -827,10 +828,14 @@ struct slow5_hdr *slow5_hdr_init(FILE *fp, enum slow5_fmt format, slow5_press_me
827828
SLOW5_ERROR("Malformed blow5 header. Failed to read the signal compression method.%s", feof(fp) ? " EOF reached." : "");
828829
goto err_fread;
829830
} else if (fseek(fp, SLOW5_BINARY_HDR_SIZE_OFFSET, SEEK_SET) == -1) {
830-
SLOW5_ERROR("Failed to fseek() to offset %ld: %s.", SLOW5_BINARY_HDR_SIZE_OFFSET, strerror(errno));
831-
free(header);
832-
slow5_errno = SLOW5_ERR_IO;
833-
return NULL;
831+
SLOW5_WARNING("Failed to fseek() to offset %ld: %s.", SLOW5_BINARY_HDR_SIZE_OFFSET, strerror(errno));
832+
uint8_t padding[SLOW5_BINARY_HDR_SIZE_OFFSET];
833+
if(SLOW5_FREAD(padding, 50, 1, fp) != 1) { //would not work for different slow5 versions.
834+
SLOW5_ERROR("Malformed blow5 header. Failed to read the padding.%s", feof(fp) ? " EOF reached." : "");
835+
free(header);
836+
slow5_errno = SLOW5_ERR_IO;
837+
return NULL;
838+
}
834839
} else if (SLOW5_FREAD(&header_size, sizeof header_size, 1, fp) != 1) {
835840
SLOW5_ERROR("Malformed blow5 header. Failed to read the ascii header size.%s", feof(fp) ? " EOF reached." : "");
836841
goto err_fread;

0 commit comments

Comments
 (0)