2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
13 static const char sccsid
[] = "$Id: ex_file.c,v 10.13 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $";
16 #include <sys/types.h>
17 #include <sys/queue.h>
19 #include <bitstring.h>
26 #include "../common/common.h"
29 * ex_file -- :f[ile] [name]
30 * Change the file's name and display the status line.
32 * PUBLIC: int ex_file __P((SCR *, EXCMD *));
52 /* Make sure can allocate enough space. */
53 INT2CHAR(sp
, cmdp
->argv
[0]->bp
, cmdp
->argv
[0]->len
+ 1,
55 if ((p
= v_strdup(sp
, np
, nlen
- 1)) == NULL
)
58 /* If already have a file name, it becomes the alternate. */
59 if (!F_ISSET(frp
, FR_TMPFILE
))
60 set_alt_name(sp
, frp
->name
);
62 /* Free the previous name. */
67 * The file has a real name, it's no longer a temporary,
68 * clear the temporary file flags.
70 F_CLR(frp
, FR_TMPEXIT
| FR_TMPFILE
);
72 /* Have to force a write if the file exists, next time. */
73 F_SET(frp
, FR_NAMECHANGE
);
75 /* Notify the screen. */
76 (void)sp
->gp
->scr_rename(sp
, sp
->frp
->name
, 1);
81 msgq_status(sp
, sp
->lno
, MSTAT_SHOWLAST
);