hedgewars/uPhysFSLayer.pas
changeset 11631 b3db79b56f28
parent 11155 a10143c3d87d
child 11632 cac74d9075be
equal deleted inserted replaced
11629:c2e6df2cfac7 11631:b3db79b56f28
    11 {$IFNDEF WIN32}
    11 {$IFNDEF WIN32}
    12     {$linklib physfs}
    12     {$linklib physfs}
    13     {$linklib physlayer}
    13     {$linklib physlayer}
    14 {$ENDIF}
    14 {$ENDIF}
    15 
    15 
    16 procedure initModule;
    16 procedure initModule(localPrefix, userPrefix: PChar);
    17 procedure freeModule;
    17 procedure freeModule;
    18 
    18 
    19 type PFSFile = pointer;
    19 type PFSFile = pointer;
    20 
    20 
    21 function rwopsOpenRead(fname: shortstring): PSDL_RWops;
    21 function rwopsOpenRead(fname: shortstring): PSDL_RWops;
   136 end;
   136 end;
   137 
   137 
   138 procedure pfsMount(path: ansistring; mountpoint: PChar);
   138 procedure pfsMount(path: ansistring; mountpoint: PChar);
   139 begin
   139 begin
   140     if PHYSFS_mount(PChar(path), mountpoint, false) then
   140     if PHYSFS_mount(PChar(path), mountpoint, false) then
   141         AddFileLog('[PhysFS] mount ' + shortstring(path) + ' at ' + shortstring(mountpoint) + ' : ok')
   141         //AddFileLog('[PhysFS] mount ' + shortstring(path) + ' at ' + shortstring(mountpoint) + ' : ok')
   142     else
   142     else
   143         AddFileLog('[PhysFS] mount ' + shortstring(path) + ' at ' + shortstring(mountpoint) + ' : FAILED ("' + shortstring(PHYSFS_getLastError()) + '")');
   143         //AddFileLog('[PhysFS] mount ' + shortstring(path) + ' at ' + shortstring(mountpoint) + ' : FAILED ("' + shortstring(PHYSFS_getLastError()) + '")');
   144 end;
   144 end;
   145 
   145 
   146 procedure pfsMountAtRoot(path: ansistring);
   146 procedure pfsMountAtRoot(path: ansistring);
   147 begin
   147 begin
   148     pfsMount(path, PChar(_S'/'));
   148     pfsMount(path, PChar(_S'/'));
   149 end;
   149 end;
   150 
   150 
   151 procedure initModule;
   151 procedure initModule(localPrefix, userPrefix: PChar);
   152 var i: LongInt;
   152 var i: LongInt;
   153     cPhysfsId: shortstring;
   153     cPhysfsId: shortstring;
   154 {$IFNDEF MOBILE}
   154 {$IFNDEF MOBILE}
   155     fp: PChar;
   155     fp: PChar;
   156 {$ENDIF}
   156 {$ENDIF}
   169     // mount system fonts paths first
   169     // mount system fonts paths first
   170     for i:= low(cFontsPaths) to high(cFontsPaths) do
   170     for i:= low(cFontsPaths) to high(cFontsPaths) do
   171         begin
   171         begin
   172             fp := cFontsPaths[i];
   172             fp := cFontsPaths[i];
   173             if fp <> nil then
   173             if fp <> nil then
   174                 pfsMount(ansistring(fp), PChar('/Fonts'));
   174                 pfsMount(ansistring(fp), _P'/Fonts');
   175         end;
   175         end;
   176 {$ENDIF}
   176 {$ENDIF}
   177 
   177 
   178     pfsMountAtRoot(PathPrefix);
   178     pfsMountAtRoot(localPrefix);
   179     pfsMountAtRoot(UserPathPrefix + ansistring('/Data'));
   179     pfsMountAtRoot(userPrefix + ansistring('/Data'));
   180 
   180 
   181     hedgewarsMountPackages;
   181     hedgewarsMountPackages;
   182 
   182 
   183     // need access to teams and frontend configs (for bindings)
   183     // need access to teams and frontend configs (for bindings)
   184     pfsMountAtRoot(UserPathPrefix);
   184     pfsMountAtRoot(userPrefix);
   185 
   185 
   186     if cTestLua then
   186     if cTestLua then
   187         begin
   187         begin
   188             pfsMountAtRoot(ansistring(ExtractFileDir(cScriptName)));
   188             pfsMountAtRoot(ansistring(ExtractFileDir(cScriptName)));
   189             cScriptName := ExtractFileName(cScriptName);
   189             cScriptName := ExtractFileName(cScriptName);