-
Notifications
You must be signed in to change notification settings - Fork 2
/
mmarch.dpr
580 lines (473 loc) · 18 KB
/
mmarch.dpr
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
// mmarch
// Command line tool to handle Heroes 3 and Might and Magic 6, 7, 8
// resource archive files (e.g. lod files). Based on GrayFace's MMArchive.
// By Tom CHEN <tomchen.org@gmail.com> (tomchen.org)
// MIT License
// https://github.com/might-and-magic/mmarch
program mmarch;
{$R *.res}
{$APPTYPE CONSOLE}
uses
Windows, SysUtils, StrUtils, Classes, RSLod, MMArchMain, MMArchPath, MMArchCompare, RSQ;
type
MissingParamException = class(Exception);
const
MMARCHVERSION: string = '3.2';
MMARCHURL: string = 'https://github.com/might-and-magic/mmarch';
var
method, archiveFile: string;
methodNumber: integer;
resourcestring
NeedFolder = 'You must specify a folder (use `.` for current folder)';
NeedFileToAdd = 'You must specify at least one file to add';
NeedFileToDelete = 'You must specify at least one file to delete';
NeedFilesToRename = 'You must specify a file to rename, and a file name that the file will be renamed to';
NeedArchiveFileTypeAndFolder = 'You must specify a type of your archive file that will be created and a folder (use `.` for current folder)';
NeedArchiveFilesToMerge = 'You must specify two archive files to be merged together';
InsufficientParameters = 'Insufficient parameters';
NeedArchiveFile = 'You must specify an archive file';
UnknownMethod = 'Unknown method: `%s`';
UnknownCompareOption = 'Unknown compare option: `%s`';
OldDiffFolderEmpty = 'Folder `%s` is empty';
HELPSTR_FirstLine = 'mmarch Version %s Usage:';
HELPSTR_ReqOpt = '(`%s`: required; `%s`: optional; `%s`: or):';
HELPSTR_Initial = 'Initial letter of the first argument can be used (e.g. `%s` for `%s`)';
HELPSTR_CaseInsensitive = 'File names are case-insensitive';
HELPSTR_UseNotations = 'You can use the following notations';
HELPSTR_CurrentFolder = 'current folder';
HELPSTR_AllFiles = 'all files';
HELPSTR_AllFilesWExt = 'all files with specified extension';
HELPSTR_AllFilesWOExt = 'all files without extension';
HELPSTR_ReadDetails = 'Read README.md file or go to the following page for more details and examples:';
HELPSTR_Colon = ': ';
HELPSTR_BatchArchive = '%s in `%s`';
HELPSTR_FilePath = 'File path:';
HELPSTR_AllDirRecur = 'all directories recursively';
HELPSTR_AnyOneDir = 'any ONE directory';
HELPSTR_FileName = 'File name at the end:';
HELPSTR_AllArchive = 'all supported archive files';
HELPSTR_AllArchiveWExt = 'all supported archive files with specified extension';
HELPSTR_AllArchiveWAnyExt = 'all supported archive files with any of specified extensions';
HELPPRM_ARCHIVE_FILE = 'ARCHIVE_FILE';
HELPPRM_FOLDER = 'FOLDER';
HELPPRM_FILE_TO_EXTRACT_1 = 'FILE_TO_EXTRACT_1';
HELPPRM_FILE_TO_EXTRACT_2 = 'FILE_TO_EXTRACT_2';
HELPPRM_SEPARATOR = 'SEPARATOR';
HELPPRM_FILE_TO_ADD_1 = 'FILE_TO_ADD_1';
HELPPRM_FILE_TO_ADD_2 = 'FILE_TO_ADD_2';
HELPPRM_FILE_TO_DELETE_1 = 'FILE_TO_DELETE_1';
HELPPRM_FILE_TO_DELETE_2 = 'FILE_TO_DELETE_2';
HELPPRM_OLD_FILE_NAME = 'OLD_FILE_NAME';
HELPPRM_NEW_FILE_NAME = 'NEW_FILE_NAME';
HELPPRM_ARCHIVE_FILE_TYPE = 'ARCHIVE_FILE_TYPE';
HELPPRM_ARCHIVE_FILE_2 = 'ARCHIVE_FILE_2';
HELPPRM_ARCHIVE_FILE_OR_FOLDER = 'ARCHIVE_FILE_OR_FOLDER';
HELPPRM_ARCHIVE_FILE_OR_FOLDER_2 = 'ARCHIVE_FILE_OR_FOLDER_2';
HELPPRM_DIFF_FOLDER = 'DIFF_FOLDER';
HELPPRM_DIFF_FOLDER_NAME = 'DIFF_FOLDER_NAME';
HELPPRM_OLD_DIFF_FOLDER = 'OLD_DIFF_FOLDER';
HELPPRM_SCRIPT_FILE = 'SCRIPT_FILE';
HELPPRM_FILE_TO_XX_X = 'FILE_TO_XX_?';
procedure help(short: boolean = false);
begin
WriteLn(format(HELPSTR_FirstLine, [MMARCHVERSION]));
WriteLn;
WriteLn('mmarch extract <' + HELPPRM_ARCHIVE_FILE + '> <' + HELPPRM_FOLDER + '> [' + HELPPRM_FILE_TO_EXTRACT_1 + '] [' + HELPPRM_FILE_TO_EXTRACT_2 + '] [...]');
WriteLn('mmarch list <' + HELPPRM_ARCHIVE_FILE + '> [' + HELPPRM_SEPARATOR + ']');
WriteLn('mmarch add <' + HELPPRM_ARCHIVE_FILE + '> <' + HELPPRM_FILE_TO_ADD_1 + '> [' + HELPPRM_FILE_TO_ADD_2 + '] [...]');
WriteLn('mmarch delete <' + HELPPRM_ARCHIVE_FILE + '> <' + HELPPRM_FILE_TO_DELETE_1 + '> [' + HELPPRM_FILE_TO_DELETE_2 + '] [...]');
WriteLn('mmarch rename <' + HELPPRM_ARCHIVE_FILE + '> <' + HELPPRM_OLD_FILE_NAME + '> <' + HELPPRM_NEW_FILE_NAME + '>');
WriteLn('mmarch create <' + HELPPRM_ARCHIVE_FILE + '> <' + HELPPRM_ARCHIVE_FILE_TYPE + '> <' + HELPPRM_FOLDER + '> [' + HELPPRM_FILE_TO_ADD_1 + '] [' + HELPPRM_FILE_TO_ADD_2 + '] [...]');
WriteLn('mmarch merge <' + HELPPRM_ARCHIVE_FILE + '> <' + HELPPRM_ARCHIVE_FILE_2 + '>');
WriteLn('mmarch compare <' + HELPPRM_ARCHIVE_FILE_OR_FOLDER + '> <' + HELPPRM_ARCHIVE_FILE_OR_FOLDER_2 + '>');
WriteLn('mmarch compare <' + HELPPRM_ARCHIVE_FILE_OR_FOLDER + '> <' + HELPPRM_ARCHIVE_FILE_OR_FOLDER_2 + '> {nsis|batch} <' + HELPPRM_SCRIPT_FILE + '> <' + HELPPRM_DIFF_FOLDER_NAME + '>');
WriteLn('mmarch compare <' + HELPPRM_ARCHIVE_FILE_OR_FOLDER + '> <' + HELPPRM_ARCHIVE_FILE_OR_FOLDER_2 + '> filesonly <' + HELPPRM_DIFF_FOLDER + '>');
WriteLn('mmarch diff-files-to-{nsis|batch} <' + HELPPRM_OLD_DIFF_FOLDER + '> <' + HELPPRM_SCRIPT_FILE + '> <' + HELPPRM_DIFF_FOLDER_NAME + '>');
WriteLn('mmarch diff-add-keep <' + HELPPRM_DIFF_FOLDER + '>');
WriteLn('mmarch optimize <' + HELPPRM_ARCHIVE_FILE + '>');
WriteLn('mmarch help');
if not short then
begin
WriteLn;
WriteLn(format(HELPSTR_ReqOpt, ['<>', '[]', '|']));
WriteLn;
WriteLn('- ' + format(HELPSTR_Initial, ['e', 'extract']));
WriteLn('- ' + HELPSTR_CaseInsensitive);
WriteLn('- ' + HELPSTR_UseNotations);
WriteLn;
WriteLn(HELPPRM_FOLDER + HELPSTR_Colon);
WriteLn(' . ' + HELPSTR_CurrentFolder);
WriteLn;
WriteLn(HELPPRM_FILE_TO_XX_X + HELPSTR_Colon);
WriteLn('*.* | * ' + HELPSTR_AllFiles);
WriteLn(' *.txt ' + HELPSTR_AllFilesWExt);
WriteLn(' *. ' + HELPSTR_AllFilesWOExt);
WriteLn;
WriteLn(format(HELPSTR_BatchArchive, [HELPPRM_ARCHIVE_FILE, 'mmarch extract']) + HELPSTR_Colon);
WriteLn(HELPSTR_FilePath);
WriteLn(' ** ' + HELPSTR_AllDirRecur);
WriteLn(' * ' + HELPSTR_AnyOneDir);
WriteLn(HELPSTR_FileName);
WriteLn('*.* | * ' + HELPSTR_AllArchive);
WriteLn(' *.lod ' + HELPSTR_AllArchiveWExt);
WriteLn('*.lod|lwd|vid ' + HELPSTR_AllArchiveWAnyExt);
WriteLn;
WriteLn(HELPSTR_ReadDetails);
WriteLn(MMARCHURL);
end;
end;
procedure extract;
var
archSimp: MMArchSimple;
extractToBaseFolder, extractToFolder, archiveFileFolder, fileName: string;
i, j: integer;
archiveFileList: TStringList; // archive file name - archive file path pair
begin
extractToBaseFolder := ParamStr(3);
if extractToBaseFolder = '' then
raise MissingParamException.Create(NeedFolder);
extractToFolder := extractToBaseFolder;
if Pos('*', archiveFile) > 0 then
archiveFileList := wildcardArchiveNameToArchiveList(archiveFile)
else
begin
archiveFileList := TStringList.Create;
archiveFileList.Clear;
archiveFileList.NameValueSeparator := nameValSeparator;
archiveFileList.Add(archiveFile + nameValSeparator + '.');
end;
for j := 0 to archiveFileList.Count - 1 do
begin
try // the individual archive file will be skipped if it gets an exception
archiveFileFolder := archiveFileList.ValueFromIndex[j];
archSimp := MMArchSimple.load(withTrailingSlash(archiveFileFolder) + archiveFileList.Names[j]);
fileName := ParamStr(4);
if Pos('*', archiveFile) > 0 then
extractToFolder := withTrailingSlash(extractToBaseFolder)
+ withTrailingSlash(archiveFileFolder)
+ archiveFileList.Names[j] + MMArchiveExt;
if fileName = '' then // FILE_TO_EXTRACT_1 is empty, extract all
archSimp.extractAll(extractToFolder);
for i := 4 to ParamCount do
begin
fileName := ParamStr(i);
if fileName <> '' then
begin
if Pos('*', fileName) > 0 then
archSimp.extractAll(extractToFolder, wildcardFileNameToExt(fileName))
else
begin
try // the individual resource file will be skipped if it gets an exception
archSimp.extract(extractToFolder, fileName);
except
on E: Exception do
begin
WriteLn(format(FileInArchiveErrorStr, [beautifyPath(fileName),
beautifyPath(withTrailingSlash(archiveFileFolder) + archiveFileList.Names[j])]));
WriteLn(E.Message);
end;
end;
end;
end;
end;
except
on E: Exception do
begin
WriteLn(format(ArchiveFileErrorStr,
[beautifyPath(withTrailingSlash(archiveFileFolder) + archiveFileList.Names[j])]));
WriteLn(E.Message);
end;
end;
end;
archiveFileList.Free;
end;
procedure list;
var
archSimp: MMArchSimple;
separator: string;
begin
separator := ParamStr(3);
if separator = '' then
separator := #13#10;
archSimp := MMArchSimple.load(archiveFile);
Write(archSimp.list(separator));
end;
procedure addProc(archSimp: MMArchSimple; paramIndexFrom: integer);
var
filePath, ext, folder, fileName: string;
i, paletteIndex: integer;
begin
i := paramIndexFrom;
while i <= ParamCount do
begin
filePath := ParamStr(i);
if filePath <> '' then // has file to add
begin
folder := ExtractFilePath(filePath);
fileName := ExtractFileName(filePath);
ext := ExtractFileName(fileName);
if Pos('*', fileName) > 0 then
archSimp.addAll(folder, wildcardFileNameToExt(fileName))
else
begin
if (i <= ParamCount - 2) and (SameText(ParamStr(i + 1), '/p')) then // pal specified
begin
paletteIndex := strtoint(ParamStr(i + 2));
try // the individual resource file will be skipped if it gets an exception
archSimp.add(filePath, paletteIndex);
except
on E: Exception do
WriteLn(format(FileErrorStr, [beautifyPath(filePath), E.Message]));
end;
i := i + 2;
end
else
begin
try // the individual resource file will be skipped if it gets an exception
archSimp.add(filePath);
except
on E: Exception do
WriteLn(format(FileErrorStr, [beautifyPath(filePath), E.Message]));
end;
end;
end;
end;
i := i + 1; // increment no matter what
end;
end;
procedure add;
var
filePath: string;
archSimp: MMArchSimple;
begin
filePath := ParamStr(3);
if filePath = '' then
raise MissingParamException.Create(NeedFileToAdd);
archSimp := MMArchSimple.load(archiveFile);
addProc(archSimp, 3);
end;
procedure delete;
var
fileName: string;
archSimp: MMArchSimple;
i: integer;
begin
fileName := ParamStr(3);
if fileName = '' then
raise MissingParamException.Create(NeedFileToDelete);
archSimp := MMArchSimple.load(archiveFile);
for i := 3 to ParamCount do
begin
fileName := ParamStr(i);
if fileName <> '' then
begin
if Pos('*', fileName) > 0 then
archSimp.deleteAll(wildcardFileNameToExt(fileName))
else
begin
try // the individual resource file will be skipped if it gets an exception
archSimp.delete(fileName);
except
on E: Exception do
WriteLn(format(FileErrorStr, [beautifyPath(fileName), E.Message]));
end;
end;
end;
end;
end;
procedure rename;
var
oldFileName, newFileName: string;
archSimp: MMArchSimple;
begin
oldFileName := ParamStr(3);
newFileName := ParamStr(4);
if (oldFileName = '') or (newFileName = '') then
raise MissingParamException.Create(NeedFilesToRename);
archSimp := MMArchSimple.load(archiveFile);
archSimp.rename(oldFileName, newFileName);
end;
procedure create;
var
archiveFileType, folder: string;
archSimp: MMArchSimple;
begin
archiveFileType := ParamStr(3);
folder := ParamStr(4);
if (archiveFileType = '') or (folder = '') then
raise MissingParamException.Create(NeedArchiveFileTypeAndFolder);
archSimp := MMArchSimple.create;
archSimp.new(archiveFile, archiveFileType, folder);
addProc(archSimp, 5);
end;
procedure merge;
var
archSimp: MMArchSimple;
archiveFile2: string;
begin
archiveFile2 := ParamStr(3);
if archiveFile2 = '' then
raise MissingParamException.Create(NeedArchiveFilesToMerge);
archSimp := MMArchSimple.load(archiveFile);
archSimp.merge(archiveFile2);
end;
procedure compareReport(oldArchiveOrFolder, newArchiveOrFolder: string);
begin
compareBase(oldArchiveOrFolder, newArchiveOrFolder);
end;
procedure compareFilesonly(oldArchiveOrFolder, newArchiveOrFolder, diffFileFolderName: string);
begin
compareBase(oldArchiveOrFolder, newArchiveOrFolder, diffFileFolderName);
end;
procedure diffFilesToAny(isNsis: boolean);
var
oldDiffFileFolder, scriptFilePath, diffFileFolderName, scriptFileFolder, newDiffFileFolder: string;
deletedFolderList, deletedNonResFileList, deletedResFileList, modifiedArchiveList: TStringList;
shouldGenerateScript: boolean;
begin
oldDiffFileFolder := ParamStr(2);
scriptFilePath := ParamStr(3);
diffFileFolderName := ParamStr(4);
if (oldDiffFileFolder = '') or (scriptFilePath = '') or (diffFileFolderName = '') then
raise MissingParamException.Create(InsufficientParameters);
oldDiffFileFolder := beautifyPath(oldDiffFileFolder);
if not DirectoryExists(oldDiffFileFolder) or (
(getAllFilesInFolder(oldDiffFileFolder, '*', false).Count = 0) and
(getAllFilesInFolder(oldDiffFileFolder, '*', true).Count = 0)
) then
WriteLn(format(OldDiffFolderEmpty, [oldDiffFileFolder]))
else
begin
scriptFilePath := beautifyPath(scriptFilePath);
scriptFileFolder := ExtractFilePath(scriptFilePath);
deletedFolderList := TStringList.Create;
deletedNonResFileList := TStringList.Create;
deletedResFileList := TStringList.Create;
modifiedArchiveList := TStringList.Create;
getListFromDiffFiles(oldDiffFileFolder, deletedFolderList, deletedNonResFileList, deletedResFileList, modifiedArchiveList);
newDiffFileFolder := withTrailingSlash(scriptFileFolder) + beautifyPath(diffFileFolderName);
shouldGenerateScript := true;
if not SameText(oldDiffFileFolder, newDiffFileFolder) then
shouldGenerateScript := moveDir(oldDiffFileFolder, newDiffFileFolder);
if shouldGenerateScript then
generateScript(deletedFolderList, deletedNonResFileList, deletedResFileList, modifiedArchiveList, scriptFilePath, diffFileFolderName, isNsis);
deletedFolderList.Free;
deletedNonResFileList.Free;
deletedResFileList.Free;
modifiedArchiveList.Free;
end;
end;
procedure diffFilesToNsis;
begin
diffFilesToAny(true);
end;
procedure diffFilesToBatch;
begin
diffFilesToAny(false);
end;
procedure diffAddKeep;
begin
addKeepToAllEmptyFoldersRecur(archiveFile); // archiveFile here is a folder path
end;
procedure compareAny(oldArchiveOrFolder, newArchiveOrFolder, scriptFilePath, diffFileFolderName: string; isNsis: boolean);
var
deletedFolderList, deletedNonResFileList, deletedResFileList, modifiedArchiveList: TStringList;
same: boolean;
begin
deletedFolderList := TStringList.Create;
deletedNonResFileList := TStringList.Create;
deletedResFileList := TStringList.Create;
modifiedArchiveList := TStringList.Create;
same := compareBase(oldArchiveOrFolder, newArchiveOrFolder, withTrailingSlash(ExtractFilePath(scriptFilePath)) + diffFileFolderName,
deletedFolderList, deletedNonResFileList, deletedResFileList, modifiedArchiveList);
if not same then
generateScript(deletedFolderList, deletedNonResFileList, deletedResFileList, modifiedArchiveList, scriptFilePath, diffFileFolderName, isNsis);
deletedFolderList.Free;
deletedNonResFileList.Free;
deletedResFileList.Free;
modifiedArchiveList.Free;
end;
procedure compareNsis(oldArchiveOrFolder, newArchiveOrFolder, scriptFilePath, diffFileFolderName: string);
begin
compareAny(oldArchiveOrFolder, newArchiveOrFolder, scriptFilePath, diffFileFolderName, true);
end;
procedure compareBatch(oldArchiveOrFolder, newArchiveOrFolder, scriptFilePath, diffFileFolderName: string);
begin
compareAny(oldArchiveOrFolder, newArchiveOrFolder, scriptFilePath, diffFileFolderName, false);
end;
procedure compare;
var
archiveFile2, option, p5, p6: string;
optionNumber: integer;
begin
archiveFile2 := ParamStr(3);
if archiveFile2 = '' then
raise MissingParamException.Create(NeedArchiveFilesToMerge);
option := ParamStr(4);
optionNumber := AnsiIndexStr(option,
['nsis',
'batch',
'filesonly',
'']);
p5 := ParamStr(5);
p6 := ParamStr(6);
if (p5 = '') and (optionNumber < 3) then
raise MissingParamException.Create(InsufficientParameters);
if (p6 = '') and (optionNumber < 2) then
raise MissingParamException.Create(InsufficientParameters);
Case optionNumber of
0: compareNsis(archiveFile, archiveFile2, p5, p6);
1: compareBatch(archiveFile, archiveFile2, p5, p6);
2: compareFilesonly(archiveFile, archiveFile2, p5);
3: compareReport(archiveFile, archiveFile2);
else // -1: not found in the array
raise MissingParamException.CreateFmt(UnknownCompareOption, [option]);
end;
end;
procedure optimize;
var
archSimp: MMArchSimple;
begin
archSimp := MMArchSimple.load(archiveFile);
archSimp.optimize;
end;
begin
try
method := trimCharLeft(ParamStr(1), '-');
methodNumber := AnsiIndexStr(method, ['extract', 'e', 'list', 'l',
'add', 'a', 'delete', 'd', 'rename', 'r', 'create', 'c', 'merge', 'm',
'compare', 'k', 'optimize', 'o',
'diff-files-to-nsis', 'df2n', 'diff-files-to-batch', 'df2b', 'diff-add-keep', 'dak',
'help', 'h', '']);
archiveFile := ParamStr(2);
// < 24: method is not `help`
if (archiveFile = '') And (methodNumber < 24) And (methodNumber >= 0) then
raise MissingParamException.Create(NeedArchiveFile);
Case methodNumber of
0, 1: extract;
2, 3: list;
4, 5: add;
6, 7: delete;
8, 9: rename;
10, 11: create;
12, 13: merge;
14, 15: compare;
16, 17: optimize;
18, 19: diffFilesToNsis;
20, 21: diffFilesToBatch;
22, 23: diffAddKeep;
24, 25, 26: help;
else // -1: not found in the array
raise MissingParamException.CreateFmt(UnknownMethod, [method]);
end;
except
on E: MissingParamException do
begin
WriteLn(format(ErrorStr, [E.Message]));
WriteLn;
help(true);
end;
on E: Exception do
WriteLn(format(ErrorStr, [E.Message]));
end;
end.