aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes/UPlatform.pas
diff options
context:
space:
mode:
authoreddie-0815 <eddie-0815@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-11-08 21:02:07 +0000
committereddie-0815 <eddie-0815@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-11-08 21:02:07 +0000
commita0ff0b75e3562e04f17f11fc41f2e49040d620c5 (patch)
treefb9329f4a10cce9eddbed97e288a28eef13147f8 /Game/Code/Classes/UPlatform.pas
parent6ca1db26350a589b5bcb3e2eac35a7965d5ab448 (diff)
downloadusdx-a0ff0b75e3562e04f17f11fc41f2e49040d620c5.tar.gz
usdx-a0ff0b75e3562e04f17f11fc41f2e49040d620c5.tar.xz
usdx-a0ff0b75e3562e04f17f11fc41f2e49040d620c5.zip
Added UPlatform.pas. This should be the first step to move the simple platform specific code to one file for each platform to reduce the IFDEFs in the remaining files.
The first available function is a unicode capable DirectoryFindFiles. It is now used in the BrowseDir function in file USongs.pas. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@595 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/Classes/UPlatform.pas')
-rw-r--r--Game/Code/Classes/UPlatform.pas56
1 files changed, 56 insertions, 0 deletions
diff --git a/Game/Code/Classes/UPlatform.pas b/Game/Code/Classes/UPlatform.pas
new file mode 100644
index 00000000..cc971bed
--- /dev/null
+++ b/Game/Code/Classes/UPlatform.pas
@@ -0,0 +1,56 @@
+unit UPlatform;
+
+// Comment by Eddie:
+// This unit defines an interface for platform specific utility functions.
+// The Interface is implemented in separate files for each platform:
+// UPlatformWindows, UPlatformLinux and UPlatformWindows.
+
+interface
+
+{$IFDEF FPC}
+ {$MODE Delphi}
+{$ENDIF}
+
+{$I switches.inc}
+
+uses Classes;
+
+type
+
+ TDirectoryEntry = Record
+ Name : WideString;
+ IsDirectory : Boolean;
+ IsFile : Boolean;
+ end;
+
+ TDirectoryEntryArray = Array of TDirectoryEntry;
+
+ IPlatform = interface
+
+ // DirectoryFindFiles returns all files matching the filter. Do not use '*' in the filter.
+ // If you set ReturnAllSubDirs = true all directories will be returned, if yout set it to false
+ // directories are completely ignored.
+ Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray;
+ end;
+
+var
+ Platform : IPlatform;
+
+implementation
+
+uses
+ {$IFDEF MSWINDOWS}
+ UPlatformWindows;
+ {$ENDIF}
+ {$IFDEF LINUX}
+ UPlatformLinux;
+ {$ENDIF}
+ {$IFDEF DARWIN}
+ UPlatformMacOSX;
+ {$ENDIF}
+
+initialization
+
+ Platform := TPlatform.Create;
+
+end.