hedgewars/uPhysFSLayer.pas
branchqmlfrontend
changeset 10434 1614b13ad35e
parent 10424 4be6cd55f1cf
child 10606 8e95911cb86b
equal deleted inserted replaced
10432:b0abef0ee78c 10434:1614b13ad35e
    26 
    26 
    27 procedure pfsReadLn(f: PFSFile; var s: shortstring);
    27 procedure pfsReadLn(f: PFSFile; var s: shortstring);
    28 procedure pfsReadLnA(f: PFSFile; var s: ansistring);
    28 procedure pfsReadLnA(f: PFSFile; var s: ansistring);
    29 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64;
    29 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64;
    30 function pfsEOF(f: PFSFile): boolean;
    30 function pfsEOF(f: PFSFile): boolean;
       
    31 function pfsEnumerateFiles(dir: shortstring): PPChar;
       
    32 procedure pfsFreeList(list: PPChar);
    31 
    33 
    32 function pfsExists(fname: shortstring): boolean;
    34 function pfsExists(fname: shortstring): boolean;
    33 
    35 
    34 function  physfsReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; cdecl; external PhyslayerLibName;
    36 function  physfsReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; cdecl; external PhyslayerLibName;
    35 procedure physfsReaderSetBuffer(buf: pointer); cdecl; external PhyslayerLibName;
    37 procedure physfsReaderSetBuffer(buf: pointer); cdecl; external PhyslayerLibName;
    49 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
    51 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
    50 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external PhysfsLibName;
    52 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external PhysfsLibName;
    51 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
    53 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
    52 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external PhysfsLibName;
    54 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external PhysfsLibName;
    53 function PHYSFS_getLastError(): PChar; cdecl; external PhysfsLibName;
    55 function PHYSFS_getLastError(): PChar; cdecl; external PhysfsLibName;
       
    56 function PHYSFS_enumerateFiles(dir: PChar): PPChar; cdecl; external PhysfsLibName;
       
    57 procedure PHYSFS_freeList(list: PPChar); cdecl; external PhysfsLibName;
    54 {$ELSE}
    58 {$ELSE}
    55 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64;
    59 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64;
    56 begin
    60 begin
    57     PHYSFS_readBytes:= PHYSFS_read(f, buffer, 1, len);
    61     PHYSFS_readBytes:= PHYSFS_read(f, buffer, 1, len);
    58 end;
    62 end;
    86 function pfsExists(fname: shortstring): boolean;
    90 function pfsExists(fname: shortstring): boolean;
    87 begin
    91 begin
    88     exit(PHYSFS_exists(Str2PChar(fname)))
    92     exit(PHYSFS_exists(Str2PChar(fname)))
    89 end;
    93 end;
    90 
    94 
       
    95 function pfsEnumerateFiles(dir: shortstring): PPChar;
       
    96 begin
       
    97     exit(PHYSFS_enumerateFiles(Str2PChar(dir)))
       
    98 end;
       
    99 
       
   100 procedure pfsFreeList(list: PPChar);
       
   101 begin
       
   102     PHYSFS_freeList(list)
       
   103 end;
    91 
   104 
    92 procedure pfsReadLn(f: PFSFile; var s: shortstring);
   105 procedure pfsReadLn(f: PFSFile; var s: shortstring);
    93 var c: char;
   106 var c: char;
    94 begin
   107 begin
    95 s[0]:= #0;
   108 s[0]:= #0;
   167                 pfsMount(ansistring(fp), PChar('/Fonts'));
   180                 pfsMount(ansistring(fp), PChar('/Fonts'));
   168         end;
   181         end;
   169 
   182 
   170     pfsMountAtRoot(localPrefix);
   183     pfsMountAtRoot(localPrefix);
   171     pfsMountAtRoot(userPrefix + ansistring('/Data'));
   184     pfsMountAtRoot(userPrefix + ansistring('/Data'));
       
   185     pfsMount(userPrefix, PChar('/Config'));
   172 
   186 
   173     hedgewarsMountPackages;
   187     hedgewarsMountPackages;
   174 
       
   175     // need access to teams and frontend configs (for bindings)
       
   176     pfsMountAtRoot(userPrefix);
       
   177 
   188 
   178     {$IFNDEF PAS2C}
   189     {$IFNDEF PAS2C}
   179     if cTestLua then
   190     if cTestLua then
   180         begin
   191         begin
   181             pfsMountAtRoot(ExtractFileDir(cScriptName));
   192             pfsMountAtRoot(ExtractFileDir(cScriptName));