-
Notifications
You must be signed in to change notification settings - Fork 1
/
Unit1.pas
261 lines (222 loc) · 7.81 KB
/
Unit1.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
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
unit Unit1;
interface
uses
Windows, Dialogs, StdCtrls, Buttons, ComCtrls, Controls, ExtCtrls,
Classes, Forms,ShellAPI, SysUtils, Graphics;
type
TForm1 = class(TForm)
SpeedButton1: TSpeedButton;
Label1: TLabel;
Shape1: TShape;
Shape2: TShape;
SpeedButton2: TSpeedButton;
Label2: TLabel;
Edit_FL_Name: TEdit;
Edit_NF_Folder: TEdit;
Label3: TLabel;
Label4: TLabel;
Shape3: TShape;
SpeedButton3: TSpeedButton;
Panel1: TPanel;
ProgressBar1: TProgressBar;
Bevel1: TBevel;
Bevel2: TBevel;
Label5: TLabel;
SpeedButton4: TSpeedButton;
Shape4: TShape;
Shape5: TShape;
OpenDialog1: TOpenDialog;
Bevel3: TBevel;
Label6: TLabel;
Panel_FCopy: TPanel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
CheckBox_PF: TCheckBox;
Label10: TLabel;
Timer1: TTimer;
Timer2: TTimer;
Label11: TLabel;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
flag_stop_proc: boolean;
Spisok: TStrings;
implementation
uses Unit2, unit3;
{$R *.dfm}
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
if OpenDialog1.Execute then begin
Edit_FL_Name.Text:=Opendialog1.FileName;
Edit_FL_Name.SelStart:=length(Edit_FL_Name.Text);
end else Edit_FL_Name.Text:='';
ProgressBar1.Min:=1; ProgressBar1.Max:=1;
ProgressBar1.Position:=1;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
form2.ShowModal;
Edit_NF_Folder.SetFocus;
if form2.StaticText1.Caption='' then Edit_NF_Folder.Text:='';
ProgressBar1.Min:=1; ProgressBar1.Max:=1;
ProgressBar1.Position:=1;
end;
procedure TForm1.SpeedButton4Click(Sender: TObject);
label 1,2;
var numb_generator, kol_udach_fail, kol_neudach_fail: integer;
i,k: integer; fc, fe, fuf: boolean;
s, st: string; f: textFile;
begin
if Edit_FL_Name.Text='' then begin
showmessage('Âûáåðèòå ôàéë ñî ñïèñêîì !'); exit;
end;
if Edit_NF_Folder.Text='' then begin
showmessage('Âûáåðèòå ïàïêó äëÿ êîïèðîâàíèÿ !'); exit;
end;
if MessageDlg('Âû ïðàâèëüíî âûáðàëè êàòàëîã-öåëü ?',
mtConfirmation, [mbNo, mbYes],0) <> mrYes then exit;
if not DirectoryExists(Edit_NF_Folder.Text) then
if not CreateDir(Edit_NF_Folder.Text) then begin
MessageDlg('Ïðîáëåìû ñ êàòàëîãîì íàçíà÷åíèÿ',
mtError, [mbOk],0); Edit_NF_Folder.Text:=''; beep;
exit;
end;
ProgressBar1.Min:=1; ProgressBar1.Max:=1; ProgressBar1.Position:=1;
Spisok.Clear; Panel_FCopy.Visible:=true; application.ProcessMessages;
try
AssignFile(F, Edit_FL_Name.Text); Reset(F);
st:=ExtractFilePath(Edit_FL_Name.Text);
while not eof(f) do begin Readln(f, s);
{ Ôèëüòð -ASX- }
if OpenDialog1.FilterIndex=1 then begin
k:=pos('<Ref href',s);
if k>0 then begin
delete(s,1,13); delete(s,length(s)-2,4);
Spisok.add(s);
end; end;
{ Ôèëüòð -M3U- }
if OpenDialog1.FilterIndex=2 then begin
if s[1]<>'#' then begin
{ Çàùèòà äëÿ ôàéëîâ ñ äðóãîãî äèñêà }
if ExtractFileDrive(s)='' then s:=st+s;
Spisok.add(s);
end; end;
application.ProcessMessages;
end;
CloseFile(F);
except
showmessage('Ïðîáëåìû ñ ôàéëîì. Ñîððè !');
Panel_FCopy.Visible:=false; application.ProcessMessages; exit;
end;
flag_stop_proc:=false; if Spisok.Text='' then exit;
label8.Caption:='Ïðîèñõîäèò êîïèðîâàíèå '+inttostr(Spisok.count)+
' ôàëîâ(-à)';
application.ProcessMessages;
ProgressBar1.Max:=Spisok.count; numb_generator:=1;
kol_udach_fail:=0; kol_neudach_fail:=0; form3.memo1.Clear;
form3.Memo1.Lines.Add('Íåóäà÷íî ñêîïèðîâàííûå/óäàëåííûå ôàéëû:');
form3.Memo1.Lines.Add(''); fe:=false;
{ MUSCAT - Processor }
for i:=1 to Spisok.count do begin
if not FileExists(pwidechar(Spisok[i-1])) then begin
inc(kol_neudach_fail);
form3.Memo1.Lines.add(inttostr(kol_neudach_fail)+') '+Spisok[i-1]);
ProgressBar1.Position:=i; application.ProcessMessages; continue;
end;
try SetFileAttributes(pwidechar('\\?\'+Spisok[i-1]),FILE_ATTRIBUTE_NORMAL); except end;
if CheckBox_PF.Checked then begin
fuf:=movefile(pwidechar(Spisok[i-1]),
pwidechar(Edit_NF_Folder.Text+ExtractFileName(Spisok[i-1])))
end else begin
fuf:=copyfile(pwidechar(Spisok[i-1]),
pwidechar(Edit_NF_Folder.Text+ExtractFileName(Spisok[i-1])), true)
end;
if not fuf then begin
1: if flag_stop_proc then break;
fc:=copyfile(pwidechar(Spisok[i-1]),
pwidechar(Edit_NF_Folder.Text+
'('+inttostr(numb_generator)+') '+
ExtractFileName(Spisok[i-1])), true);
inc(numb_generator); application.ProcessMessages;
if not fc then begin
if not FileExists(Edit_NF_Folder.Text+
ExtractFileName(Spisok[i-1])) then begin
inc(kol_neudach_fail);
form3.Memo1.Lines.add(inttostr(kol_neudach_fail)+') '+
Spisok[i-1]);
ProgressBar1.Position:=i;
application.ProcessMessages; continue;
end else goto 1;
end else inc(kol_udach_fail);
end else inc(kol_udach_fail);
ProgressBar1.Position:=i; application.ProcessMessages;
if CheckBox_PF.Checked and fc then begin
try
try SetFileAttributes(pwidechar('\\?\'+Spisok[i-1]),FILE_ATTRIBUTE_NORMAL); except end;
if not DeleteFile(pwidechar(Spisok[i-1])) then begin
fe:=true; form3.Memo1.Lines.add('[íå óäàëåí->] '+Spisok[i-1]);
end;
except
fe:=true; form3.Memo1.Lines.add('[íå óäàëåí->] '+Spisok[i-1]);
end;
end;
if flag_stop_proc then break;
end;
Panel_FCopy.Visible:=false; application.ProcessMessages;
{ MUSCAT - Informer }
if (Spisok.count=kol_udach_fail) and (not fe) then
showmessage('Ok. Âñå ãîòîâî!');
if (Spisok.count=kol_udach_fail) and (fe) then begin
showmessage('Âñå ôàéëû ñêîïèðîâàíû. À óäàëåíû íå âñå ...');
ProgressBar1.Min:=1; ProgressBar1.Max:=1; ProgressBar1.Position:=1;
goto 2;
end;
if (Spisok.count<>kol_udach_fail) then begin
showmessage('Ê ñîæàëåíèþ, '+inttostr(Spisok.count-kol_udach_fail)+
' ôàéë(-îâ) íå ñêîïèðîâàíû!');
ProgressBar1.Min:=1; ProgressBar1.Max:=1; ProgressBar1.Position:=1;
if (kol_neudach_fail>0) or (fe) then begin
2: form3.Memo1.Lines.Add('');
form3.Memo1.Lines.Add('Òàê áûâàåò, íå ðàññòðàèâàéòåñü !');
form3.showmodal;
end;
end;
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
flag_stop_proc:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Spisok := TStringList.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Spisok.Free;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if label10.font.Color=clMaroon then label10.font.Color:=clNavy
else label10.font.Color:=clMaroon;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
if fsUnderline in label11.font.Style then label11.font.Style:=
label11.font.Style-[fsunderline] else
label11.font.Style:=
label11.font.Style+[fsunderline];
end;
end.