hedgewars/uPhysFSLayer.pas
author unc0rr
Wed, 14 Nov 2012 22:45:36 +0400
branchphysfslayer
changeset 8025 07862ab415c8
parent 8022 10b3b93c1f56
child 8028 dc30104660d3
permissions -rw-r--r--
Get rid of Pathz and UserPathz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7959
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
     1
unit uPhysFSLayer;
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
     2
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
     3
{$LINKLIB ../bin/libphysfs.a}
8022
10b3b93c1f56 - Add physfsrwops library
unc0rr
parents: 7963
diff changeset
     4
{$LINKLIB ../bin/libphysfsrwops.a}
7959
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
     5
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
     6
interface
8022
10b3b93c1f56 - Add physfsrwops library
unc0rr
parents: 7963
diff changeset
     7
uses SDLh;
7959
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
     8
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
     9
procedure initModule;
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    10
procedure freeModule;
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    11
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    12
function rwopsOpenRead(fname: shortstring): PSDL_RWops;
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    13
function rwopsOpenWrite(fname: shortstring): PSDL_RWops;
8022
10b3b93c1f56 - Add physfsrwops library
unc0rr
parents: 7963
diff changeset
    14
7959
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    15
implementation
8022
10b3b93c1f56 - Add physfsrwops library
unc0rr
parents: 7963
diff changeset
    16
uses uUtils, uVariables;
7959
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    17
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    18
function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external;
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    19
function PHYSFS_deinit() : LongInt; cdecl; external;
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    20
function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl; external;
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    21
function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external;
7959
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    22
7963
9910f303f5b6 Fix function prototype
unc0rr
parents: 7959
diff changeset
    23
function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external;
7959
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    24
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    25
function rwopsOpenRead(fname: shortstring): PSDL_RWops;
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    26
begin
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    27
    exit(PHYSFSRWOPS_openRead(Str2PChar(fname)));
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    28
end;
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    29
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    30
function rwopsOpenWrite(fname: shortstring): PSDL_RWops;
7959
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    31
begin
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    32
    exit(PHYSFSRWOPS_openWrite(Str2PChar(fname)));
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    33
end;
8022
10b3b93c1f56 - Add physfsrwops library
unc0rr
parents: 7963
diff changeset
    34
8025
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    35
procedure initModule;
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    36
var i: LongInt;
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    37
begin
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    38
    i:= PHYSFS_init(Str2PChar(ParamStr(0)));
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    39
    AddFileLog('[PhysFS] init: ' + inttostr(i));
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    40
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    41
    i:= PHYSFS_mount(Str2PChar(PathPrefix), nil, true);
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    42
    AddFileLog('[PhysFS] mount ' + PathPrefix + ': ' + inttostr(i));
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    43
    i:= PHYSFS_mount(Str2PChar(UserPathPrefix), nil, true);
07862ab415c8 Get rid of Pathz and UserPathz
unc0rr
parents: 8022
diff changeset
    44
    AddFileLog('[PhysFS] mount ' + UserPathPrefix + ': ' + inttostr(i));
7959
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    45
end;
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    46
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    47
procedure freeModule;
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    48
begin
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    49
    PHYSFS_deinit;
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    50
end;
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    51
644b757d20e6 Start work on physfs support in engine
unc0rr
parents:
diff changeset
    52
end.