hedgewars/uPhysFSLayer.pas
changeset 11648 3bff941c035f
parent 11637 cac74d9075be
child 11649 f17df78181d8
equal deleted inserted replaced
11647:c82a0a886779 11648:3bff941c035f
   177         pfsBlockRead:= 0
   177         pfsBlockRead:= 0
   178     else
   178     else
   179         pfsBlockRead:= r
   179         pfsBlockRead:= r
   180 end;
   180 end;
   181 
   181 
   182 procedure pfsMount(path: ansistring; mountpoint: PChar);
   182 procedure pfsMount(path: PChar; mountpoint: PChar);
   183 begin
   183 begin
   184     if PHYSFS_mount(PChar(path), mountpoint, false) then
   184     if PHYSFS_mount(path, mountpoint, false) then
   185         //AddFileLog('[PhysFS] mount ' + shortstring(path) + ' at ' + shortstring(mountpoint) + ' : ok')
   185         AddFileLog('[PhysFS] mount ' + shortstring(path) + ' at ' + shortstring(mountpoint) + ' : ok')
   186     else
   186     else
   187         //AddFileLog('[PhysFS] mount ' + shortstring(path) + ' at ' + shortstring(mountpoint) + ' : FAILED ("' + shortstring(PHYSFS_getLastError()) + '")');
   187         AddFileLog('[PhysFS] mount ' + shortstring(path) + ' at ' + shortstring(mountpoint) + ' : FAILED ("' + shortstring(PHYSFS_getLastError()) + '")');
   188 end;
   188 end;
   189 
   189 
   190 procedure pfsMountAtRoot(path: ansistring);
   190 procedure pfsMountAtRoot(path: PChar);
   191 begin
   191 begin
   192     pfsMount(path, PChar(_S'/'));
   192     pfsMount(path, PChar(_S'/'));
   193 end;
   193 end;
   194 
   194 
   195 procedure initModule(localPrefix, userPrefix: PChar);
   195 procedure initModule(localPrefix, userPrefix: PChar);
   213     // mount system fonts paths first
   213     // mount system fonts paths first
   214     for i:= low(cFontsPaths) to high(cFontsPaths) do
   214     for i:= low(cFontsPaths) to high(cFontsPaths) do
   215         begin
   215         begin
   216             fp := cFontsPaths[i];
   216             fp := cFontsPaths[i];
   217             if fp <> nil then
   217             if fp <> nil then
   218                 pfsMount(ansistring(fp), _P'/Fonts');
   218                 pfsMount(fp, _P'/Fonts');
   219         end;
   219         end;
   220 {$ENDIF}
   220 {$ENDIF}
   221 
   221 
   222     pfsMountAtRoot(localPrefix);
   222     pfsMountAtRoot(localPrefix);
   223     pfsMount(userPrefix, PChar('/Config'));
   223     pfsMount(userPrefix, PChar('/Config'));
   224     pfsMakeDir('/Config/Data');
   224     pfsMakeDir('/Config/Data');
   225     pfsMakeDir('/Config/Logs');
   225     pfsMakeDir('/Config/Logs');
   226     pfsMountAtRoot(userPrefix + ansistring('/Data'));
   226     pfsMountAtRoot(Str2PChar(shortstring(userPrefix) + '/Data'));
   227     PHYSFS_setWriteDir(userPrefix);
   227     PHYSFS_setWriteDir(userPrefix);
   228 
   228 
   229     hedgewarsMountPackages;
   229     hedgewarsMountPackages;
   230 
   230 
   231     // need access to teams and frontend configs (for bindings)
   231     // need access to teams and frontend configs (for bindings)
   232     pfsMountAtRoot(userPrefix);
   232     pfsMountAtRoot(userPrefix);
   233 
   233 
   234     if cTestLua then
   234     if cTestLua then
   235         begin
   235         begin
   236             pfsMountAtRoot(ansistring(ExtractFileDir(cScriptName)));
   236             pfsMountAtRoot(Str2PChar(ExtractFileDir(cScriptName)));
   237             cScriptName := ExtractFileName(cScriptName);
   237             cScriptName := ExtractFileName(cScriptName);
   238         end;
   238         end;
   239 end;
   239 end;
   240 
   240 
   241 procedure freeModule;
   241 procedure freeModule;