hedgewars/uPhysFSLayer.pas
changeset 8073 5a289ef40fdb
parent 8067 34a679e5ca9d
child 8077 2ea5cde93abc
equal deleted inserted replaced
8072:c803d89ae74d 8073:5a289ef40fdb
     1 unit uPhysFSLayer;
     1 unit uPhysFSLayer;
     2 {$IFDEF ANDROID}
       
     3     {$linklib physfs}
       
     4     {$linklib physfsrwops}
       
     5 {$ELSE}
       
     6     {$LINKLIB ../bin/libphysfs.a}
       
     7     {$LINKLIB ../bin/libphysfsrwops.a}
       
     8 {$ENDIF}
       
     9 
       
    10 {$IFDEF WIN32}
       
    11     {$LINKLIB kernel32}
       
    12     {$LINKLIB user32}
       
    13     {$LINKLIB shell32}
       
    14     {$LINKLIB advapi32}
       
    15     {$LINKLIB msvcrt}
       
    16 {$ENDIF}
       
    17 
       
    18 {$IFDEF DARWIN}
       
    19     {$LINKFRAMEWORK IOKit}
       
    20 {$ENDIF}
       
    21 
     2 
    22 interface
     3 interface
    23 uses SDLh;
     4 uses SDLh;
       
     5 
       
     6 {$IFDEF ANDROID}
       
     7     {$linklib physfs}
       
     8 {$ELSE}
       
     9     {$IFNDEF WIN32}
       
    10         {$linklib ../bin/libphysfs.a}
       
    11     {$ENDIF}
       
    12     {$IFDEF DARWIN}
       
    13         {$LINKFRAMEWORK IOKit}
       
    14     {$ENDIF}
       
    15 {$ENDIF}
       
    16 
       
    17 const
       
    18 {$IFDEF WIN32}
       
    19     PhysfsLibName = 'libphysfs';
       
    20 {$ELSE}
       
    21     {$IFDEF DARWIN}
       
    22     PhysfsLibName = 'physfs';
       
    23     {$ELSE}
       
    24     PhysfsLibName = 'physfs.a';
       
    25     {$ENDIF}
       
    26 {$ENDIF}
    24 
    27 
    25 procedure initModule;
    28 procedure initModule;
    26 procedure freeModule;
    29 procedure freeModule;
    27 
    30 
    28 type PFSFile = pointer;
    31 type PFSFile = pointer;
    40 function pfsExists(fname: shortstring): boolean;
    43 function pfsExists(fname: shortstring): boolean;
    41 
    44 
    42 implementation
    45 implementation
    43 uses uUtils, uVariables;
    46 uses uUtils, uVariables;
    44 
    47 
    45 function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external;
    48 function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external PhysfsLibName;
    46 function PHYSFS_deinit() : LongInt; cdecl; external;
    49 function PHYSFS_deinit() : LongInt; cdecl; external PhysfsLibName;
    47 function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl; external;
    50 function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl ; external PhysfsLibName;
    48 function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external;
    51 function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external PhysfsLibName;
    49 
    52 
    50 function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external;
    53 function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external PhysfsLibName;
    51 function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external;
    54 function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external PhysfsLibName;
    52 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external;
    55 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
    53 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external;
    56 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external PhysfsLibName;
    54 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external;
    57 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
    55 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external;
    58 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external PhysfsLibName;
    56 
    59 
    57 procedure hedgewarsMountPackages(); cdecl; external;
    60 procedure hedgewarsMountPackages(); cdecl; external PhysfsLibName;
    58 
    61 
    59 function rwopsOpenRead(fname: shortstring): PSDL_RWops;
    62 function rwopsOpenRead(fname: shortstring): PSDL_RWops;
    60 begin
    63 begin
    61     exit(PHYSFSRWOPS_openRead(Str2PChar(fname)));
    64     exit(PHYSFSRWOPS_openRead(Str2PChar(fname)));
    62 end;
    65 end;