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.
12 #include <sys/types.h>
13 #include <sys/queue.h>
16 #include <bitstring.h>
23 #include "../common/common.h"
26 * ex_file -- :f[ile] [name]
27 * Change the file's name and display the status line.
29 * PUBLIC: int ex_file(SCR *, EXCMD *);
32 ex_file(SCR
*sp
, EXCMD
*cmdp
)
47 /* Make sure can allocate enough space. */
48 INT2CHAR(sp
, cmdp
->argv
[0]->bp
, cmdp
->argv
[0]->len
+ 1,
50 if ((p
= v_strdup(sp
, np
, nlen
- 1)) == NULL
)
53 /* If already have a file name, it becomes the alternate. */
54 if (!F_ISSET(frp
, FR_TMPFILE
))
55 set_alt_name(sp
, frp
->name
);
57 /* Free the previous name. */
62 * The file has a real name, it's no longer a temporary,
63 * clear the temporary file flags.
65 F_CLR(frp
, FR_TMPEXIT
| FR_TMPFILE
);
67 /* Have to force a write if the file exists, next time. */
68 F_SET(frp
, FR_NAMECHANGE
);
70 /* Notify the screen. */
71 (void)sp
->gp
->scr_rename(sp
, sp
->frp
->name
, 1);
76 msgq_status(sp
, sp
->lno
, MSTAT_SHOWLAST
);