aboutsummaryrefslogtreecommitdiff
path: root/sys/imio/iki/stf/stfdelete.x
blob: dd319f12faac73f98962d85557149f58b1ebdaee (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
37
38
39
40
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<error.h>
include	<imhdr.h>
include	"stf.h"

# STF_DELETE -- Delete an image.  A special operator is required since the
# image is stored as two files.

procedure stf_delete (kernel, root, extn, status)

int	kernel			#I IKI kernel
char	root[ARB]		#I root filename
char	extn[ARB]		#U header file extension
int	status			#O return value

pointer	sp
pointer	hdr_fname, pix_fname
int	access()

begin
	call smark (sp)
	call salloc (hdr_fname, SZ_PATHNAME, TY_CHAR)
	call salloc (pix_fname, SZ_PATHNAME, TY_CHAR)

	# Generate filename.
	call iki_mkfname (root, extn, Memc[hdr_fname], SZ_PATHNAME)
	call stf_mkpixfname (root, extn, Memc[pix_fname], SZ_PATHNAME)

	# If the header cannot be deleted, leave the pixfile alone.
	iferr (call delete (Memc[hdr_fname]))
	    call erract (EA_WARN)
	else if (access (Memc[pix_fname],0,0) == YES) {
	    iferr (call delete (Memc[pix_fname]))
		call erract (EA_WARN)
	}

	status = OK
	call sfree (sp)
end