diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2010-08-22 13:48:20 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2010-08-22 13:48:20 +0200 |
commit | 95a19394a4a584eb6e71d4047a07b16f16416d37 (patch) | |
tree | 16c2bb42fa9b51ffcc17d03678f996b0efa94bac /src/corelib/gdi | |
parent | d9a8635bbb6271e934795ee2125f60a061c4ea62 (diff) | |
download | fpGUI-95a19394a4a584eb6e71d4047a07b16f16416d37.tar.xz |
Introduced a new cross-platform fpgFileSize() helper function.
Diffstat (limited to 'src/corelib/gdi')
-rw-r--r-- | src/corelib/gdi/fpg_utils_impl.inc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/corelib/gdi/fpg_utils_impl.inc b/src/corelib/gdi/fpg_utils_impl.inc index d3bb2f0c..08a3c3ad 100644 --- a/src/corelib/gdi/fpg_utils_impl.inc +++ b/src/corelib/gdi/fpg_utils_impl.inc @@ -1,7 +1,7 @@ {%mainunit fpg_utils.pas} uses - Shellapi; + Shellapi, Windows; // GDI specific implementations of encoding functions @@ -26,3 +26,22 @@ begin end; end; +function fpgFileSize(const AFilename: TfpgString): integer; +var + FindData: TWIN32FindDataW; + FindHandle: THandle; + Str: widestring; +begin + // Don't assign the widestring to TSearchRec.name because it is of type + // string, which will generate a conversion to the system encoding + Str := UTF8Decode(Filename); + FindHandle:=Windows.FindFirstFileW(PWideChar(Str), FindData); + if FindHandle=Windows.Invalid_Handle_value then + begin + Result:=-1; + exit; + end; + Result := (int64(FindData.nFileSizeHigh) shl 32)+FindData.nFileSizeLow; + Windows.FindClose(FindHandle); +end; + |