summaryrefslogtreecommitdiff
path: root/src/corelib/gdi
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/gdi')
-rw-r--r--src/corelib/gdi/fpg_utils_impl.inc21
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;
+