File: fdevblk.x

package info (click to toggle)
iraf 2.18.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,000 kB
  • sloc: ansic: 115,890; fortran: 74,576; lisp: 18,888; yacc: 5,642; sh: 961; lex: 596; makefile: 509; asm: 159; csh: 54; xml: 33; sed: 4
file content (42 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download | duplicates (7)
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
41
42
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<syserr.h>
include	<fset.h>

# FDEVBLK -- Get the device block size of the device on which the named logical
# directory resides.  The named logical directory must have write permission.
# A file pathname may be used to pass the logical directory name.

int procedure fdevblk (path)

char	path[ARB]			# pathname of directory or file

pointer	sp, fname, ldir, tempfn
int	fd, junk, block_size
int	fstati(), open(), fnldir()
errchk	mktemp, open, close

begin
	call smark (sp)
	call salloc (ldir,   SZ_PATHNAME, TY_CHAR)
	call salloc (fname,  SZ_PATHNAME, TY_CHAR)
	call salloc (tempfn, SZ_PATHNAME, TY_CHAR)

	# Generate the name of a temporary file in named directory.
	junk = fnldir (path, Memc[ldir], SZ_PATHNAME)
	call strcpy (Memc[ldir], Memc[fname], SZ_PATHNAME)
	call strcat ("zbk", Memc[fname], SZ_PATHNAME)
	call mktemp (Memc[fname], Memc[tempfn], SZ_PATHNAME)

	# Open the file and get the device block size.
	iferr {
	    fd = open (Memc[tempfn], NEW_FILE, BINARY_FILE)
	    block_size = fstati (fd, F_BLKSIZE)
	    call close (fd)
	    call delete (Memc[tempfn])
	} then
	    call syserrs (SYS_FACCDIR, Memc[ldir])

	call sfree (sp)
	return (block_size)
end