-
-/*
- * 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
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
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;
}