X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/8cebca1119664be52f1cbccd0ee052ae0b8c1de0..ab6e546854f67cf582fd67a3d54813fce5aa34ac:/sbr/seq_save.c diff --git a/sbr/seq_save.c b/sbr/seq_save.c index 5b06dcdf..f95b4436 100644 --- a/sbr/seq_save.c +++ b/sbr/seq_save.c @@ -1,6 +1,4 @@ - -/* - * seq_save.c -- 1) synchronize sequences +/* seq_save.c -- 1) synchronize sequences * -- 2) save public sequences * * This code is Copyright (c) 2002, by the authors of nmh. See the @@ -77,6 +75,8 @@ priv: context_del (attr); /* delete sequence from context */ if (!fp) { + int failed_to_lock = 0; + /* * Attempt to open file for public sequences. * If that fails (probably because folder is @@ -89,11 +89,19 @@ priv: free(mp->seqname); mp->seqname = NULL; rewind(fp); - ftruncate(fileno(fp), 0); - } else if ((fp = lkfopendata (seqfile, "w")) == NULL + if (ftruncate(fileno(fp), 0) < 0) { + advise ("sequence file", "ftruncate"); + } + } else if ((fp = lkfopendata (seqfile, "w", &failed_to_lock)) + == NULL && (m_unlink (seqfile) == -1 || - (fp = lkfopendata (seqfile, "w")) == NULL)) { - admonish (attr, "unable to write"); + (fp = lkfopendata (seqfile, "w", &failed_to_lock)) + == NULL)) { + if (failed_to_lock) { + admonish (attr, "unable to lock"); + } else { + admonish (attr, "unable to write"); + } goto priv; }