Разработка файловой оболочки
Информация - Компьютеры, программирование
Другие материалы по предмету Компьютеры, программирование
r;
Exit;
end;
MainForm.CMDirList.Items.Delete(i);
end;
end;
Function DesideSlash(str:string):integer;
// Подсчёт количества "\" для сортировки
Var
D,r:integer;
begin
d:=0;
for r:=0 to Length(str) do
if str[r]=\ then d:=d+1;
DesideSlash:=D;
end;
Procedure SortCMDirList;
//Пузырьковая сортировка списка директорий
Var i:integer;
Strl,StrH:string;
Flag:Boolean;
begin
Flag:=False;
if MainForm.CMDirList.Items.Count=0 then Flag:=true;
1then"> If MainForm.CMDirList.Items.Count<>1 then
repeat
For i:=0 to MainForm.CMDirList.Items.Count-2 do
begin
strl:=MainForm.CMDirList.Items[i];
StrH:=MainForm.CMDirList.Items[i+1];
if DesideSlash(StrL)>DesideSlash(StrH) then
begin
MainForm.CMDirList.Items[i]:=StrH;
MainForm.CMDirList.Items[i+1]:=StrL;
end;
end;
For i:=0 to MainForm.CMDirList.Items.Count-2 do
begin
if DesideSlash(MainForm.CMDirList.Items[i])<=DesideSlash(MainForm.CMDirList.Items[i+1]) then
begin
Flag:=True;
end
else
begin
Flag:=False;
Break;
end;
end;
Until (Flag);
end;
Procedure CreateOneDirInDes(d,s,str:string);
Var i,Point:integer;
begin
For i:=0 to Length(str) do
if (str[i]<>s[i]) or (str[i]=\) then
begin
if (Str[i]=\) and (Str[i+1]=S[i+1]) then Point:=i
else break;
end;
if D[Length(D)]=\ then Point:=Point+1;
For i:=Point to Length(str) do
d:=d+str[i];
if not CreateDir(D) then
begin
end
else
begin
MainForm.Directory.SetDirectory(D);
MainForm.Directory.BuildTree;
end;
end;
Procedure CreateDirInDestin(S,D:string);
//Создание дерева директорий при копировании /переносе
Var
P,i,j:integer;str,str1:string;
EndFor:integer;
begin
MainForm.StatusBar.Panels[1].Text:=Build destination Tree, Please Wait....;
SortCMDirList;
For i:=0 to MainForm.CMDirList.Items.Count-1 do
begin
str:=MainForm.CMDirList.Items[i];
CreateOneDirInDes(D,S,str);
end;
end;
Function CheskSizeInDestination:boolean;
// Проверка доступного места на диске
Var
i:integer;
Size:integer;
begin
For i:=0 to MainForm.CMFileList.Items.Count-1 do
size:=size+GetFileSize(MainForm.CMFileList.Items[i]);
if DiskFree(0) < size then
CheskSizeInDestination:=False
else
CheskSizeInDestination:=True;
end;
Function CreateDestinPathForFile(S,D,f:string):string;
Var
Point,i:integer;
begin
For i:=0 to Length(s) do
if S[i]=\ then Point:=i;
if D[Length(d)]=\ then Point:=Point+1;
For i:=Point to Length(f) do
d:=d+f[i];
For i:=Length(d) downTo 0 do
if D[i]=\ then
begin
D[i+1]:=#0;
Break;
end;
CreateDestinPathForFile:=d;
end;
Procedure PasteFileInDest(S,D:string);
//Вставка файлов при копир. /перен. директории
Var
i:integer;
Str:string;
F:String;
begin
MainForm.Directory.Repaint;
GetFormToCenter(ProgressForm);
ProgressForm.Show;
SizeAllCopy:=GetSizeAllFiles(MainForm.CMFileList);
0)do"> While (MainForm.CMFileList.Items.Count<>0) do
begin
Str:=CreateDestinPathForFile(S,D,MainForm.CMFileList.Items[0]);
CopyFile(MainForm.CMFileList.Items[0],Str);
If not DoingWithDir then
DelOneFile(MainForm.CMFileList.Items[0],False);
MainForm.CMFileList.Items.Delete(0);
end;
ProgressForm.Close;
MainForm.FileList.Update;
end;
Procedure PasteDirectory(SDir,DDir:string);
//Вставка директории
Var
i:integer;
begin
if CheskSizeInDestination then
begin
CreateDirInDestin(SDir,DDir);
PasteFileInDest(Sdir,DDir);
if not DoingWithDir then
begin
end;
end
else
begin
if DoingWithDir then
begin
Application.MessageBox(Not Free Spase,Error,MB_APPLMODAL+MB_OK);
end
else
begin
end;
end;
end;
Procedure DelOneFile(dFile:string;Flag:boolean);
//Удаление одного файла
Var
F:TSearchRec;
begin
if flag then
begin
FileSetAttr(dFile,faArchive);
DeleteFile(dFile)
end
else
begin
FindFirst(dFile,faAnyFile,F);
if (F.Attr=32) or (F.Attr=0) then
DeleteFile(dFile)
else
begin
AskDeleteCurrentFile.FileName.Caption:=F.Name;
AskDeleteCurrentFile.FileName.Caption:=AskDeleteCurrentFile.FileName.Caption+ is Read Only;
AskDeleteCurrentFile.ShowModal;
if not No Then
begin
FileSetAttr(dFile,faArchive);
DeleteFile(dFile);
end;
end;
end;
FindClose(f);
end;
end.
Форма поиска файлов по маске
unit UFindForm; // Форма поиска файлов
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, Tabnotbk, StdCtrls, Buttons, Menus, ExtCtrls;
type
TFindForm = class(TForm)
FileWasFind: TListBox;
StatusFind: TStatusBar;
Table: TTabbedNotebook;
BitBtn1: TBitBtn;
CBFindMask: TComboBox;
Label1: TLabel;
GroupBox1: TGroupBox;
RBCurDir: TRadioButton;
RBCurDrive: TRadioButton;
RBAllDrives: TRadioButton;
GroupBox2: TGroupBox;
LCurDir: TLabel;
ExitSearch: TButton;
Label2: TLabel;
Label3: TLabel;
DateIsAfter: TDateTimePicker;
DateIsBefore: TDateTimePicker;
Label4: TLabel;
Label5: TLabel;
SGreater: TEdit;
SLess: TEdit;
CBAdvSearch: TCheckBox;
Menu: TPopupMenu;
Run1: TMenuItem;
GoTo1: TMenuItem;
CBCase: TCheckBox;
B2: TBitBtn;
B1: TButton;
Timer1: TTimer;
procedure FormActivate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure CBFindMaskDropDown(Sender: TObject);
procedure RBCurDirClick(Sender: TObject);
procedure RBCurDriveClick(Sender: TObject);
procedure RBAllDrivesClick(Sender: TObject);
procedure ExitSearchClick(Sender: TObject);
procedure CBAdvSearchClick(Sender: TObject);
procedure MenuPopup(Sender: TObject);
procedure Run1Click(Sender: TObject);
procedure GoTo1Click(Sender: TObject);
procedure B2Click(Sender: TObject);
procedure B1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
public
Procedure FindInCurrentDir(CurDir:string);
end;
Type
PRec = ^TRec;
TRec = record
Name:TSearchRec;
SubDir:string;
Next:PRec;
end;
var
FindForm: TFindForm;
FileMaskToFind:array[1..10] of string;
EndFindFlag:boolean;
Procedure ZdvigMask(s:string);
Procedure InitFileMask;
Procedure WhereFind;
Procedure FindFile;
Procedure FindInAllDr;
function CompareFileWithMask(FileName:string):boolean;
implementation
uses UMainForm,FmxUtils;
{$R *.DFM}
function CompareFileWithMask(FileName:string):boolean;
//Сравнение имени и расширения очередного файла с маской
Var
MaskN,Mask,MaskR,FN,FR:string;
EndFor,i,j:integer;
tmp,R:boolean;
begin
FN:=;
Mask:=FindForm.CBFindMask.Text;
if not FindForm.CBCase.Checked then
begin
Mask:=UpperCase(Mask);
FileName:=UpperCase(FileName);
end;
FR:=ExtractFileExt(FileName);
For i:=1 to Length(FileName) do
if FileName[i]<>. then
FN:=FN+FileName[i]
else break;
For i:=1 to Length(Mask) do
if Mask[i]<>. then
MaskN:=MaskN+Mask[i]
else break;
MaskR:=ExtractFileExt(Mask);
//начало мучений с расширением
if Length(MaskR)&l