[fpc-pascal] Obtain file size?
Sven Barth
pascaldragon at googlemail.com
Sat Oct 7 13:11:49 CEST 2017
Am 07.10.2017 01:13 schrieb "James Richters" <james at productionautomation.net
>:
>
> I am wondering how to get the file size reported by the OS for a
particular file without opening it. I tried to search for ‘Free Pascal
File Size’ and variations but all I get are things like this:
>
>
>
> https://www.freepascal.org/docs-html/rtl/system/filesize.html
>
>
>
> which is not what I’m looking for.
>
>
>
> I’ve been looking through the sysutils reference here:
>
> https://www.freepascal.org/docs-html/rtl/sysutils/index-5.html
>
>
>
> and I see disk size, but not file size…
>
>
>
> Could someone please point me in the right direction?
TSearchRec contains a Size field so you can use FindFirst with the specific
filename instead of a pattern (don't forget FindClose then ;) ) to have a
cross platform solution.
Otherwise you'd need to use system specific mechanisms (e.g.
GetFileAttributeEx on Windows, stat on *nix).
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20171007/4a2adb69/attachment.html>
More information about the fpc-pascal
mailing list