forked from bgbennyboy/Monkey-Island-Explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uMIExplorer_Funcs.pas
87 lines (75 loc) · 2.08 KB
/
uMIExplorer_Funcs.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
******************************************************
Monkey Island Explorer
Copyright (c) 2010 - 2018 Bennyboy
Http://quickandeasysoftware.net
******************************************************
}
unit uMIExplorer_Funcs;
interface
uses
Sysutils, Windows, JCLRegistry;
function GetMI1SEPath: string;
function GetMI2SEPath: string;
function SanitiseFileName(FileName: string): string;
function ExtractPartialPath(FileName: string): string;
function SwapEndianDWord(Value: integer): integer; register;
implementation
function GetMI1SEPath: string;
const
ExtraPath: string = 'steamapps\common\the secret of monkey island special edition\';
var
Temp: string;
begin
Result := '';
try
Temp:= IncludeTrailingPathDelimiter(RegReadString(HKEY_CURRENT_USER, 'SOFTWARE\Valve\Steam', 'SteamPath'));
result:=Temp + ExtraPath;
Result := StringReplace(Result, '/', '\', [rfReplaceAll, rfIgnoreCase ]);
except on EJCLRegistryError do
result:='';
end;
end;
function GetMI2SEPath: string;
const
ExtraPath: string = 'steamapps\common\monkey2\';
var
Temp: string;
begin
Result := '';
try
Temp:= IncludeTrailingPathDelimiter(RegReadString(HKEY_CURRENT_USER, 'SOFTWARE\Valve\Steam', 'SteamPath'));
result:=Temp + ExtraPath;
Result := StringReplace(Result, '/', '\', [rfReplaceAll, rfIgnoreCase ]);
except on EJCLRegistryError do
result:='';
end;
end;
function SanitiseFileName(FileName: string): string;
var
DelimiterPos: integer;
begin
DelimiterPos := LastDelimiter('/', FileName );
if DelimiterPos = 0 then
result := FileName
else
Result := Copy( FileName, DelimiterPos + 1, Length(FileName) - DelimiterPos + 1);
end;
function ExtractPartialPath(FileName: string): string;
var
DelimiterPos: integer;
begin
DelimiterPos := LastDelimiter('/', FileName );
if DelimiterPos = 0 then
result := ''
else
begin
Result := Copy( FileName, 1, DelimiterPos);
Result := StringReplace(Result, '/', '\', [rfReplaceAll, rfIgnoreCase ]);
end;
end;
function SwapEndianDWord(Value: integer): integer; register;
asm
bswap eax
end;
end.