Idiom # 95: Get file size
See programming-idioms.org:
Code
The variable x
in this case will be of type outcome
i64
, i.e., it will be either the file size or an instance
of error
in case the file size could not be determined.
A match
expression is needed to extract the size.
Alternatively, the following code forcefully extracts the size from the
result, but will crash in case of an error:
Running Example
last changed: 2024-07-01