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.14 2001/06/25 15:19:16 skimo Exp $";
16 #include <sys/types.h>
17 #include <sys/queue.h>
20 #include <bitstring.h>
27 #include "../common/common.h"
30 * ex_file -- :f[ile] [name]
31 * Change the file's name and display the status line.
33 * PUBLIC: int ex_file(SCR *, EXCMD *);
36 ex_file(SCR
*sp
, EXCMD
*cmdp
)
51 /* Make sure can allocate enough space. */
52 INT2CHAR(sp
, cmdp
->argv
[0]->bp
, cmdp
->argv
[0]->len
+ 1,
54 if ((p
= v_strdup(sp
, np
, nlen
- 1)) == NULL
)
57 /* If already have a file name, it becomes the alternate. */
58 if (!F_ISSET(frp
, FR_TMPFILE
))
59 set_alt_name(sp
, frp
->name
);
61 /* Free the previous name. */
66 * The file has a real name, it's no longer a temporary,
67 * clear the temporary file flags.
69 F_CLR(frp
, FR_TMPEXIT
| FR_TMPFILE
);
71 /* Have to force a write if the file exists, next time. */
72 F_SET(frp
, FR_NAMECHANGE
);
74 /* Notify the screen. */
75 (void)sp
->gp
->scr_rename(sp
, sp
->frp
->name
, 1);
80 msgq_status(sp
, sp
->lno
, MSTAT_SHOWLAST
);