Програмне забезпеченння для адміністрування комп'ютерного клубу, страница 16

found:=true;

Earlier:=true

end;

if orded1>orded2 then begin

found:=true;

Earlier:=false

end;

i:=i+1

end;

if not found then begin

if length(st1)>length(st2) then Earlier:=false

else Earlier:=true

end

end;


 



procedure CompleteFiles(maindir,nowdir:string);

var f:tsearchrec;

i,j,index:word;

stmus,st:string;

begin

copyfiles.listbox.clear;

if not (ansilowercase(maindir)=ansilowercase(nowdir)) then

copyfiles.listbox.Items.Add('..');

numdirs:=0;

numfiles:=0;

currdir:=nowdir;

//Dirs

if findfirst(nowdir+'\*.*',faDirectory,f)=0 then begin

if (itsfolder(nowdir+'\'+f.name))and(f.name<>'.')and(f.name<>'..') then begin

inc(numdirs);

f.name:=ansiuppercase(f.name);

dirs[1]:=f.name+'\'

end;

while findnext(f)=0 do begin

if (itsfolder(nowdir+'\'+f.name))and(f.name<>'.')and(f.name<>'..') then begin

inc(numdirs);

f.name:=ansiuppercase(f.name);

dirs[numdirs]:=f.name+'\'

end

end;

findclose(f);

if numdirs>2 then begin

for i:=1 to numdirs-1 do begin

index:=i;

for j:=i+1 to numdirs do

if not earlier(dirs[index],dirs[j]) then index:=j;

stmus:=dirs[i];

dirs[i]:=dirs[index];

dirs[index]:=stmus

end

end

end;

if findfirst(nowdir+'\*.*',faAnyFile-faDirectory,f)=0 then begin

inc(numfiles);

f.name:=ansilowercase(f.name);

st:=f.name[1];

st:=ansiuppercase(st);

f.name[1]:=st[1];

files[1]:=f.name;

while findnext(f)=0 do begin

inc(numfiles);

f.name:=ansilowercase(f.name);

st:=f.name[1];

st:=ansiuppercase(st);

f.name[1]:=st[1];

files[numfiles]:=f.name

end;

findclose(f);

if numfiles>2 then begin

for i:=1 to numfiles-1 do begin

index:=i;

for j:=i+1 to numfiles do

if not earlier(files[index],files[j]) then index:=j;

stmus:=files[i];

files[i]:=files[index];

files[index]:=stmus

end

end

end;

for i:=1 to numdirs do

copyfiles.listbox.items.add(dirs[i]);

for i:=1 to numfiles do

copyfiles.listbox.items.add(files[i]);

end;

procedure InitCopying;

begin

bigdir:=maindir;

ddir:=destdir;

completefiles(maindir,maindir)

end;

procedure TCopyFiles.ListBoxClick(Sender: TObject);

var i:word;

index:integer;

st:string;

begin

index:=-1;

for i:=0 to listbox.items.count-1 do

if listbox.selected[i] then index:=i;

if index=-1 then exit;

st:=listbox.items.strings[index];

//Updir

if st='..' then begin

index:=-1;

for i:=1 to length(currdir) do

if currdir[i]='\' then index:=i;

delete(currdir,index,length(currdir)-index+1);

completefiles(bigdir,currdir);

exit

end;

//Lowdir

if st[length(st)]='\' then begin

delete(st,length(st),1);

completefiles(bigdir,currdir+'\'+st);

exit

end;

//File

copybuttonclick(self)

end;

procedure TCopyFiles.CopyButtonClick(Sender: TObject);

var i:word;

selected:boolean;

fromfile,tofile:string;

total:word;

begin

//Check maxcopied files number

total:=0;

for i:=0 to listbox.items.count-1 do

if listbox.selected[i] then inc(total);

if total>MAXCOPIED then begin

showmessage('Нельзя скопировать - слишком много файлов для копирования');

exit

end;

//

selected:=false;

for i:=0 to listbox.items.count-1 do

if listbox.selected[i] then begin

selected:=true;

if listbox.items.strings[i][length(listbox.items.strings[i])]='\' then begin

showmessage('Нельзя копировать папки');

exit

end

end;

if (not selected) then exit;

numcopied:=0;

for i:=0 to listbox.items.count-1 do

if listbox.selected[i] then begin

fromfile:=currdir+'\'+listbox.items.strings[i];

tofile:=ddir+'\'+listbox.items.strings[i];

inc(numcopied);

copied[numcopied]:=tofile;

copyfile(pchar(fromfile),pchar(tofile),false)

end;

modalresult:=mrOk

end;

procedure DeleteCopied;

var i:word;

begin

for i:=1 to numcopied do

deletefile(copied[i]);

numcopied:=0

end;

 



procedure TCopyFiles.FormCreate(Sender: TObject);

begin

copyfilescreated:=true

end;

initialization

numcopied:=0;