summaryrefslogtreecommitdiff
path: root/ipl/procs/filesize.icn
blob: 9aca1242b6587cd07b53768f8fed6317983fab72 (plain)
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
############################################################################
#
#	File:     filesize.icn
#
#	Subject:  Procedure to get the size of a file
#
#	Author:   Ralph E. Griswold
#
#	Date:     July 9, 1998
#
############################################################################
#
#  This file is in the public domain.
#
############################################################################
#
#  filesize(s)	returns the number of characters in the file named s; it
#		fails if s cannot be opened.
#
############################################################################

procedure filesize(s)			#: file size
   local input, size

   input := open(s) | fail

   size := 0

   while size +:= *reads(input, 10000)

   close(input)

   return size

end