update to 1.01
[nvi.git] / ex / ex_preserve.c
blob088915ad116beb34a9215029eade5571df55b10c
1 /*-
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
6 */
8 #ifndef lint
9 static char sccsid[] = "$Id: ex_preserve.c,v 8.4 1993/11/08 11:10:45 bostic Exp $ (Berkeley) $Date: 1993/11/08 11:10:45 $";
10 #endif /* not lint */
12 #include <sys/types.h>
14 #include <errno.h>
15 #include <string.h>
17 #include "vi.h"
18 #include "excmd.h"
21 * ex_preserve -- :pre[serve]
22 * Push the file to recovery.
24 int
25 ex_preserve(sp, ep, cmdp)
26 SCR *sp;
27 EXF *ep;
28 EXCMDARG *cmdp;
30 recno_t lno;
32 if (!F_ISSET(ep, F_RCV_ON)) {
33 msgq(sp, M_ERR, "Preservation of this file not possible.");
34 return (1);
37 /* If recovery not initialized, do so. */
38 if (F_ISSET(ep, F_FIRSTMODIFY) && rcv_init(sp, ep))
39 return (1);
41 /* Force the file to be read in, in case it hasn't yet. */
42 if (file_lline(sp, ep, &lno))
43 return (1);
45 /* Sync to disk. */
46 if (rcv_sync(sp, ep))
47 return (1);
49 /* Preserve the recovery files. */
50 F_SET(ep, F_RCV_NORM);
52 msgq(sp, M_INFO, "File preserved.");
53 return (0);