hedgewars/uPhysFSLayer.pas
branchphysfslayer
changeset 8034 fc032c0f7b23
parent 8031 fc40b343c45c
child 8046 4d3415927d2c
equal deleted inserted replaced
8031:fc40b343c45c 8034:fc032c0f7b23
    32 function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external;
    32 function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external;
    33 
    33 
    34 function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external;
    34 function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external;
    35 function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external;
    35 function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external;
    36 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external;
    36 function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external;
    37 function PHYSFS_read(f: PFSFile; buf: pointer; objSize: Longword; objCount: Longword): Int64; cdecl; external;
    37 function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external;
    38 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external;
    38 function PHYSFS_close(f: PFSFile): LongBool; cdecl; external;
    39 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external;
    39 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external;
    40 
    40 
    41 function rwopsOpenRead(fname: shortstring): PSDL_RWops;
    41 function rwopsOpenRead(fname: shortstring): PSDL_RWops;
    42 begin
    42 begin
    72 procedure pfsReadLn(f: PFSFile; var s: shortstring);
    72 procedure pfsReadLn(f: PFSFile; var s: shortstring);
    73 var c: char;
    73 var c: char;
    74 begin
    74 begin
    75 s[0]:= #0;
    75 s[0]:= #0;
    76 
    76 
    77 while (PHYSFS_read(f, @c, 1, 1) = 1) and (c <> #10) do
    77 while (PHYSFS_readBytes(f, @c, 1) = 1) and (c <> #10) do
    78     if (c <> #13) and (s[0] < #255) then
    78     if (c <> #13) and (s[0] < #255) then
    79         begin
    79         begin
    80         inc(s[0]);
    80         inc(s[0]);
    81         s[byte(s[0])]:= c
    81         s[byte(s[0])]:= c
    82         end
    82         end
    83 end;
    83 end;
    84 
    84 
    85 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64;
    85 function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64;
    86 var r: Int64;
    86 var r: Int64;
    87 begin
    87 begin
    88     r:= PHYSFS_read(f, buf, 1, size);
    88     r:= PHYSFS_readBytes(f, buf, size);
    89 
    89 
    90     if r <= 0 then
    90     if r <= 0 then
    91         pfsBlockRead:= 0
    91         pfsBlockRead:= 0
    92     else
    92     else
    93         pfsBlockRead:= r
    93         pfsBlockRead:= r