aboutsummaryrefslogtreecommitdiff
path: root/unix/boot/bootlib/oscrfile.c
blob: 28eec304771d2cb35d0c8ee2f32dce94d4379477 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
 */

#include <fcntl.h>
#include "bootlib.h"


/* OS_CREATEFILE -- Open a new file for writing.  Create the file with the
 * given mode bits.
 */
int
os_createfile (
  char	*fname,
  int	mode,
  int	type
)
{
	static	XINT xmode = NEW_FILE;
	PKCHAR	*osfn = (PKCHAR *) vfn2osfn (fname, 1);
	XINT	chan;
	extern  int ZOPNTX();


	if (bdebug)
	    fprintf (stderr, "create %s file `%s' -> `%s'\n",
		type == TEXT_FILE ? "text" : "binary", fname, (char *)osfn);
	osfiletype = type;

	if (type == BINARY_FILE)
	    return (creat ((char *)osfn, mode));
	else {
	    ZOPNTX (osfn, &xmode, &chan);
	    txop = text;
	    return (chan == XERR ? ERR : chan);
	}
}