hedgewars/uPhysFSLayer.pas
changeset 8310 a98c349bc06b
parent 8283 af97cdbb7713
child 8330 aaefa587e277
child 8528 ffd71e99a4f0
equal deleted inserted replaced
8309:edcfb5e43245 8310:a98c349bc06b
    38 
    38 
    39 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 PhysfsLibName;
    40 procedure physfsReaderSetBuffer(buf: pointer); cdecl; external PhysfsLibName;
    40 procedure physfsReaderSetBuffer(buf: pointer); cdecl; external PhysfsLibName;
    41 
    41 
    42 implementation
    42 implementation
    43 uses uUtils, uVariables;
    43 uses uUtils, uVariables, sysutils;
    44 
    44 
    45 function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external PhysfsLibName;
    45 function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external PhysfsLibName;
    46 function PHYSFS_deinit() : LongInt; cdecl; external PhysfsLibName;
    46 function PHYSFS_deinit() : LongInt; cdecl; external PhysfsLibName;
    47 function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl ; external PhysfsLibName;
    47 function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl ; external PhysfsLibName;
    48 function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external PhysfsLibName;
    48 function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external PhysfsLibName;
   133         pfsBlockRead:= r
   133         pfsBlockRead:= r
   134 end;
   134 end;
   135 
   135 
   136 procedure initModule;
   136 procedure initModule;
   137 var i: LongInt;
   137 var i: LongInt;
       
   138     cPhysfsId: shortstring;
   138 begin
   139 begin
   139     i:= PHYSFS_init(Str2PChar(ParamStr(0)));
   140 {$IFDEF HWLIBRARY}
       
   141     //TODO: http://icculus.org/pipermail/physfs/2011-August/001006.html
       
   142     cPhysfsId:= GetCurrentDir() + {$IFDEF DARWIN}'/Hedgewars.app/Contents/MacOS/' + {$ENDIF} ' hedgewars';
       
   143 {$ELSE}
       
   144     cPhysfsId:= ParamStr(0);
       
   145 {$ENDIF}
       
   146 
       
   147     i:= PHYSFS_init(Str2PChar(cPhysfsId));
   140     AddFileLog('[PhysFS] init: ' + inttostr(i));
   148     AddFileLog('[PhysFS] init: ' + inttostr(i));
   141 
   149 
   142     i:= PHYSFS_mount(Str2PChar(PathPrefix), nil, true);
   150     i:= PHYSFS_mount(Str2PChar(PathPrefix), nil, true);
   143     AddFileLog('[PhysFS] mount ' + PathPrefix + ': ' + inttostr(i));
   151     AddFileLog('[PhysFS] mount ' + PathPrefix + ': ' + inttostr(i));
   144     i:= PHYSFS_mount(Str2PChar(UserPathPrefix + '/Data'), nil, true);
   152     i:= PHYSFS_mount(Str2PChar(UserPathPrefix + '/Data'), nil, true);