############################################################################
#
# 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
$ifdef _POSIX
return stat(s).size
$else
input := open(s) | fail
size := 0
while size +:= *reads(input, 10000)
close(input)
return size
$endif
end
This page produced by UniDoc on 2021/04/15 @ 23:59:44.