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 least none are listed in the "File handling
overview". While a Delphi user can use the WinAPI for such tasks, a
cross-platform development system should provide according
platform-independent functions.
Or is it because you don't want to open the file at all (e.g. to
avoid modifying the timestamp of the last file access)? If this is
the case, you probably need to stick to FindFirst, etc.
These subtle problems should be considered by the implementors of such
basic general-purpose functions.
DoDi
_______________________________________________
fpc-devel maillist - [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel