hedgewars/uPhysFSLayer.pas
branchphysfslayer
changeset 8533 2d7703d6bc22
parent 8528 ffd71e99a4f0
child 8540 cf808329bb6f
equal deleted inserted replaced
8530:66cedf3e9d1e 8533:2d7703d6bc22
     1 unit uPhysFSLayer;
     1 unit uPhysFSLayer;
     2 
     2 
     3 interface
     3 interface
     4 uses SDLh, LuaPas;
     4 uses SDLh, LuaPas;
     5 
       
     6 {$LINKLIB physfs}
       
     7 {$LINKLIB physlayer}
       
     8 
       
     9 {$IFDEF DARWIN}
       
    10     {$LINKFRAMEWORK IOKit}
       
    11 {$ENDIF}
       
    12 
     5 
    13 const
     6 const
    14 {$IFDEF WIN32}
     7 {$IFDEF WIN32}
    15     PhysfsLibName = 'libphysfs';
     8     PhysfsLibName = 'libphysfs';
    16     PhyslayerLibName = 'libphyslayer';
     9     PhyslayerLibName = 'libphyslayer';
    17 {$ELSE}
    10 {$ELSE}
       
    11     {$LINKLIB physfs}
       
    12     {$LINKLIB physlayer}
    18     PhysfsLibName = 'physfs';
    13     PhysfsLibName = 'physfs';
    19     PhyslayerLibName = 'physlayer';
    14     PhyslayerLibName = 'physlayer';
       
    15 {$ENDIF}
       
    16 
       
    17 {$IFDEF DARWIN}
       
    18     {$LINKFRAMEWORK IOKit}
    20 {$ENDIF}
    19 {$ENDIF}
    21 
    20 
    22 procedure initModule;
    21 procedure initModule;
    23 procedure freeModule;
    22 procedure freeModule;
    24 
    23 
    35 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64;
    34 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64;
    36 function pfsEOF(f: PFSFile): boolean;
    35 function pfsEOF(f: PFSFile): boolean;
    37 
    36 
    38 function pfsExists(fname: shortstring): boolean;
    37 function pfsExists(fname: shortstring): boolean;
    39 
    38 
    40 function  physfsReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; cdecl; external PhysfsLibName;
    39 function  physfsReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; cdecl; external PhyslayerLibName;
    41 procedure physfsReaderSetBuffer(buf: pointer); cdecl; external PhysfsLibName;
    40 procedure physfsReaderSetBuffer(buf: pointer); cdecl; external PhyslayerLibName;
    42 
    41 
    43 implementation
    42 implementation
    44 uses uUtils, uVariables, sysutils;
    43 uses uUtils, uVariables, sysutils;
    45 
    44 
    46 function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external PhysfsLibName;
    45 function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external PhysfsLibName;
    47 function PHYSFS_deinit() : LongInt; cdecl; external PhysfsLibName;
    46 function PHYSFS_deinit() : LongInt; cdecl; external PhysfsLibName;
    48 function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl ; external PhysfsLibName;
    47 function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl ; external PhyslayerLibName;
    49 function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external PhysfsLibName;
    48 function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external PhyslayerLibName;
    50 
    49 
    51 function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external PhysfsLibName;
    50 function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external PhysfsLibName;
    52 function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external PhysfsLibName;
    51 function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external PhysfsLibName;
    53 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
    52 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
    54 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external PhysfsLibName;
    53 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external PhysfsLibName;
    55 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
    54 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
    56 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external PhysfsLibName;
    55 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external PhysfsLibName;
    57 
    56 
    58 procedure hedgewarsMountPackages(); cdecl; external PhysfsLibName;
    57 procedure hedgewarsMountPackages(); cdecl; external PhyslayerLibName;
    59 
    58 
    60 function rwopsOpenRead(fname: shortstring): PSDL_RWops;
    59 function rwopsOpenRead(fname: shortstring): PSDL_RWops;
    61 begin
    60 begin
    62     exit(PHYSFSRWOPS_openRead(Str2PChar(fname)));
    61     exit(PHYSFSRWOPS_openRead(Str2PChar(fname)));
    63 end;
    62 end;