diff -r 07862ab415c8 -r dc30104660d3 hedgewars/uPhysFSLayer.pas --- a/hedgewars/uPhysFSLayer.pas Wed Nov 14 22:45:36 2012 +0400 +++ b/hedgewars/uPhysFSLayer.pas Wed Nov 14 23:27:33 2012 +0400 @@ -9,9 +9,17 @@ procedure initModule; procedure freeModule; +type PFSFile = pointer; + function rwopsOpenRead(fname: shortstring): PSDL_RWops; function rwopsOpenWrite(fname: shortstring): PSDL_RWops; +function pfsOpenRead(fname: shortstring): PFSFile; +function pfsEOF(f: PFSFile): boolean; +function pfsClose(f: PFSFile): boolean; + +procedure pfsReadLn(f: PFSFile; var s: shortstring); + implementation uses uUtils, uVariables; @@ -21,6 +29,10 @@ function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external; function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external; +function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external; +function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external; +function PHYSFS_read(f: PFSFile; buf: pointer; objSize, objCount: Longword): Int64; cdecl; external; +function PHYSFS_close(f: PFSFile): LongBool; cdecl; external; function rwopsOpenRead(fname: shortstring): PSDL_RWops; begin @@ -32,6 +44,35 @@ exit(PHYSFSRWOPS_openWrite(Str2PChar(fname))); end; +function pfsOpenRead(fname: shortstring): PFSFile; +begin + exit(PHYSFS_openRead(Str2PChar(fname))); +end; + +function pfsEOF(f: PFSFile): boolean; +begin + exit(PHYSFS_eof(f)) +end; + +function pfsClose(f: PFSFile): boolean; +begin + exit(PHYSFS_close(f)) +end; + + +procedure pfsReadLn(f: PFSFile; var s: shortstring); +var c: char; +begin +s[0]:= #0; + +while (PHYSFS_read(f, @c, 1, 1) = 1) and (c <> #10) do + if (c <> #13) and (s[0] < #255) then + begin + inc(s[0]); + s[byte(s[0])]:= c + end +end; + procedure initModule; var i: LongInt; begin