-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFind Missing FUZ.pas
114 lines (88 loc) · 3.04 KB
/
Find Missing FUZ.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
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
{
checks in pathToCheck if there are WAV files without any corresponding FUZ files.
Run on something
}
unit userscript;
uses praUtil;
const
pathToCheck = 'Sound\Voice\SS2.esm';
extToCheck = '.fuz';
var
resultList: TStringList;
procedure checkWav(wavPath: string);
var
fuzPath: string;
begin
//resultList
fuzPath := StringReplace(wavPath, '.wav', extToCheck, 0);
if(not FileExists(DataPath+fuzPath)) then begin
AddMessage('MISSING '+fuzPath);
resultList.add(fuzPath);
end;
end;
function stripSlash(path: string): string;
begin
Result := path;
if(SameText(copy(path, length(path), 1), '\')) then begin
Result := copy(path, 0, length(path)-1);
end;
end;
function processResourceDirectoryRecursive(dir: string): boolean;
var
curFullPath: string;
searchResult : TSearchRec;
curFile: string;
begin
curFullPath := DataPath + stripSlash(dir);
Result := false;
if(not DirectoryExists(curFullPath)) then begin
exit;
end;
if FindFirst(curFullPath+'\*', faAnyFile, searchResult) = 0 then begin
repeat
// ignore . and ..
if(searchResult.Name <> '.') and (searchResult.Name <> '..') then begin
curFile := LowerCase(stripSlash(dir)+'\'+searchResult.Name);
if((searchResult.attr and faDirectory) = faDirectory) then begin
// dir
if(processResourceDirectoryRecursive(curFile)) then begin
Result := true;
end;
end else begin
if(strEndsWith(curFile, '.wav')) then begin
checkWav(curFile);
end;
end;
end;
until FindNext(searchResult) <> 0;
// Must free up resources used by these successful finds
FindClose(searchResult);
end;
end;
// called for every record selected in xEdit
function Process(e: IInterface): integer;
begin
Result := 0;
// comment this out if you don't want those messages
// AddMessage('Processing: ' + FullPath(e));
// processing code goes here
end;
// Called after processing
// You can remove it if script doesn't require finalization code
function Finalize: integer;
var
saveTo: string;
begin
Result := 0;
saveTo := ShowSaveFileDialog('Save list to', '');
if(saveTo = '') then begin
Result := 1;
exit;
end;
resultList := TStringList.create();
// do stuff
processResourceDirectoryRecursive(pathToCheck);
resultList.saveToFile(saveTo);
resultList.free();
end;
end.