On Thu, 15 Dec 2011, Hans-Peter Diettrich wrote:

Tomas Hajny schrieb:

I wonder how to obtain the size of an file on disk. The only function I could find so far is FileSize, which requires an open File, but nothing for an file name :-(

ATM FileSize(TEXT) would help, too, but FileSize only accepts an FILE, not TEXT :-(

What exactly do you want to achieve?

Effectively I'm missing a function FileSize(filename), similar to FileExists or FileAge, for general use.

Is it because the file may be open as a text and denied sharing wouldn't allow parallel opening for reading as an untyped file (as suggested by Vinzent)? If this is the case, there is a nasty but completely platform independent hack which you could use (based on the fact that the underlying operating systems and their APIs make no difference between file and text).

Normally I use TFileStream's, which have a Size property. But I find it nasty to open an file, when I only want to know its size. FPC (like Delphi) lacks some basic file/directory handling functions (Size, Remove, Rename...), at

I think you didn't look very well in the docs.

DeleteFile
RenameFile

I agree the filesize is missing.

I will look into adding them to the documentation topics.

Michael.
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to