18 lines
493 B
Plaintext
18 lines
493 B
Plaintext
function file_size(sequence file_name)
|
|
object d = dir(file_name)
|
|
if atom(d) or length(d)!=1 then return -1 end if
|
|
return d[1][D_SIZE]
|
|
end function
|
|
|
|
procedure test(sequence file_name)
|
|
integer size = file_size(file_name)
|
|
if size<0 then
|
|
printf(1,"%s file does not exist.\n",{file_name})
|
|
else
|
|
printf(1,"%s size is %d.\n",{file_name,size})
|
|
end if
|
|
end procedure
|
|
|
|
test("input.txt") -- in the current working directory
|
|
test("/input.txt") -- in the file system root
|