mirror of
https://github.com/lh3/minimap2.git
synced 2026-09-27 07:58:12 +08:00
Report errno on file opening failures and I/O errors
Add the underlying operating system error (usually "No such file" or "Out of space" respectively, but highly informative when it is not) to these error messages.
This commit is contained in:
+3
-2
@@ -2,6 +2,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "mmpriv.h"
|
||||
|
||||
FILE *mm_split_init(const char *prefix, const mm_idx_t *mi)
|
||||
@@ -13,7 +14,7 @@ FILE *mm_split_init(const char *prefix, const mm_idx_t *mi)
|
||||
sprintf(fn, "%s.%.4d.tmp", prefix, mi->index);
|
||||
if ((fp = fopen(fn, "wb")) == NULL) {
|
||||
if (mm_verbose >= 1)
|
||||
fprintf(stderr, "[ERROR]\033[1;31m failed to write to temporary file '%s'\033[0m\n", fn);
|
||||
fprintf(stderr, "[ERROR]\033[1;31m failed to write to temporary file '%s'\033[0m: %s\n", fn, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
mm_err_fwrite(&k, 4, 1, fp);
|
||||
@@ -41,7 +42,7 @@ mm_idx_t *mm_split_merge_prep(const char *prefix, int n_splits, FILE **fp, uint3
|
||||
sprintf(fn, "%s.%.4d.tmp", prefix, i);
|
||||
if ((fp[i] = fopen(fn, "rb")) == 0) {
|
||||
if (mm_verbose >= 1)
|
||||
fprintf(stderr, "ERROR: failed to open temporary file '%s'\n", fn);
|
||||
fprintf(stderr, "ERROR: failed to open temporary file '%s': %s\n", fn, strerror(errno));
|
||||
for (j = 0; j < i; ++j)
|
||||
fclose(fp[j]);
|
||||
free(fn);
|
||||
|
||||
Reference in New Issue
Block a user