} else fn = strdup(_fn);
fnidx = (char*)calloc(strlen(fn) + 5, 1);
strcpy(fnidx, fn); strcat(fnidx, ".bai");
- fp = fopen(fnidx, "r");
+ fp = fopen(fnidx, "rb");
if (fp == 0) { // try "{base}.bai"
char *s = strstr(fn, "bam");
if (s == fn + strlen(fn) - 3) {
strcpy(fnidx, fn);
fnidx[strlen(fn)-1] = 'i';
- fp = fopen(fnidx, "r");
+ fp = fopen(fnidx, "rb");
}
}
free(fnidx); free(fn);
fprintf(stderr, "[download_from_remote] fail to open remote file.\n");
return;
}
- if ((fp = fopen(fn, "w")) == 0) {
+ if ((fp = fopen(fn, "wb")) == 0) {
fprintf(stderr, "[download_from_remote] fail to create file in the working directory.\n");
knet_close(fp_remote);
return;
fnidx = (char*)calloc(strlen(fn) + 5, 1);
strcpy(fnidx, fn); strcat(fnidx, ".bai");
} else fnidx = strdup(_fnidx);
- fpidx = fopen(fnidx, "w");
+ fpidx = fopen(fnidx, "wb");
if (fpidx == 0) {
fprintf(stderr, "[bam_index_build2] fail to create the index file.\n");
free(fnidx);