-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMDX_Collect.lpr
206 lines (184 loc) · 6.27 KB
/
MDX_Collect.lpr
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
{
*****************************************************************************
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
*****************************************************************************
Author: Boban Spasic
Program description:
This program helps organizing your Yamaha DX7 SysEx collection
}
program MDX_Collect;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
Classes,
SysUtils,
CustApp,
//untUtils,
//untDXUtils,
//untDXObjInterface,
untCollectionUtils;
type
{ TMDX_Collect }
TMDX_Collect = class(TCustomApplication)
protected
procedure DoRun; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure WriteHelp; virtual;
end;
{ TMDX_Collect }
procedure TMDX_Collect.DoRun;
var
ErrorMsg: string;
fMaster: string;
fIncoming: string;
fReportDir: string;
fInputDir: string;
fOutput: string;
begin
fMaster := '';
fIncoming := '';
fReportDir := '';
fInputDir := '';
fOutput := '';
// quick check parameters
ErrorMsg := CheckOptions('hactm:i:r:d:o:',
'help analyze compare movetree master: incoming: report: dir: output:');
if ErrorMsg <> '' then
begin
WriteHelp;
ShowException(Exception.Create(ErrorMsg));
Terminate;
Exit;
end;
if (ParamCount = 0) or HasOption('h', 'help') then
begin
WriteHelp;
Terminate;
Exit;
end;
if HasOption('m', 'master') then
fMaster := GetOptionValue('m', 'master');
if HasOption('i', 'incoming') then
fIncoming := GetOptionValue('i', 'incoming');
if HasOption('r', 'report') then
fReportDir := IncludeTrailingPathDelimiter(GetOptionValue('r', 'report'));
if HasOption('d', 'dir') then
fInputDir := IncludeTrailingPathDelimiter(GetOptionValue('d', 'dir'));
if HasOption('o', 'output') then
fOutput := IncludeTrailingPathDelimiter(GetOptionValue('o', 'output'));
if HasOption('a', 'analyze') then
begin
if (fInputDir = '') or (fReportDir = '') then
begin
WriteLn('Parameter -d {directory} or parameter -r {directory} is missing or the directory could not be found');
Terminate;
Exit;
end;
if pos(':\', fInputDir) = 0 then
fInputDir := IncludeTrailingPathDelimiter(GetCurrentDir) + fInputDir;
if not DirectoryExists(fInputDir) then
begin
WriteLn('Parameter -d {directory} is missing or the directory could not be found');
Terminate;
Exit;
end
else
begin
if not DirectoryExists(fReportDir) then CreateDir(fReportDir);
WriteLn('Input directory: ' + fInputDir);
WriteLn('Report directory: ' + fReportDir);
Analyze(fInputDir, fReportDir);
WriteLn('Done!');
end;
end;
if HasOption('c', 'compare') then
begin
if (fMaster = '') or (fIncoming = '') or (fReportDir = '') then
begin
WriteLn('Some of the Parameters -m, -i or -r is missing');
Terminate;
Exit;
end
else
begin
if pos(':\', fReportDir) = 0 then
fReportDir := IncludeTrailingPathDelimiter(GetCurrentDir) + fReportDir;
WriteLn('Master list: ' + fMaster);
WriteLn('Incoming list: ' + fIncoming);
WriteLn('Reports directory: ' + fReportDir);
Compare(fMaster, fIncoming, fReportDir);
WriteLn('Done!');
end;
end;
if HasOption('t', 'movetree') then
begin
if (fOutput = '') or (fIncoming = '') or (fInputDir = '') then
begin
WriteLn('Some of the Parameters -o, -i or -d is missing');
Terminate;
Exit;
end
else
begin
WriteLn('Incoming list: ' + fIncoming);
WriteLn('Tree root directory of the incoming list: ' + fInputDir);
WriteLn('Output directory: ' + fOutput);
MoveTree(fIncoming, fInputDir, fOutput);
WriteLn('Done!');
end;
end;
Terminate;
end;
constructor TMDX_Collect.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
StopOnException := True;
end;
destructor TMDX_Collect.Destroy;
begin
inherited Destroy;
end;
procedure TMDX_Collect.WriteHelp;
begin
writeln('');
writeln('');
writeln('MDX_Collect 1.8 - tool for managing DX7 SysEx collections');
writeln('Author: Boban Spasic');
writeln('https://github.com/BobanSpasic/MDX_Tool');
writeln('');
writeln('Usage: ', ExtractFileName(ExeName), ' -parameters');
writeln(' Parameters (short and long form):');
writeln(' -h --help This help message');
writeLn('');
writeln(' -a --analyze Make a hash list of VMEM/VCED files in a directory');
writeln(' -d {directory} --dir={directory} Input directory');
writeln(' -r {directory} --report={directory} Output directory for the reports');
writeLn('');
writeln(' -c --compare Compare two hash lists');
writeln(' -m {filename} --master={filename} Hash list of your collection');
writeln(' -i {filename} --incoming={filename} Hash list of incoming collection');
writeln(' -r {directory} --report={directory} Output directory for the reports');
writeLn('');
writeln(' -t --movetree Copy directory tree to the new location and move the diff. files');
writeln(' -i {filename} --incoming={filename} IncomingHasMore.dif list of the incoming collection');
writeln(' -d {directory} --dir={directory} Root directory of the incoming file collection');
writeln(' -o {directory} --output={directory} Output directory for the moved files');
writeLn('');
writeln(' Example usage:');
writeln(' MDX_Collect -a -d MyCollection -r MyReports');
writeln(' MDX_Collect -a -d NewFiles -r NewReports');
writeln(' MDX_Collect -c -m MyCollection.hsl -i NewFiles.hsl -r MyReports');
end;
var
Application: TMDX_Collect;
begin
Application := TMDX_Collect.Create(nil);
Application.Title := 'MDX_Collect';
Application.Run;
Application.Free;
end.