1,184
社区成员
发帖
与我相关
我的任务
分享procedure TBackup.Execute;
const
Model = 'mm-dd hh:nn:ss';
var
FileList: TStrings;
FindResult: Integer;
FSearchRec: TSearchRec;
Dir, Volume, Time: string;
Handle: Thandle;
begin
FreeOnTerminate := True;
Dir := lj2 + '\ConanSandbox\Saved\';
FileList := TStringList.Create;
try
Form1.ListBox1.Clear;
FindResult := FindFirst(Dir + '*.db', faAnyFile + faDirectory, FSearchRec);
while FindResult = 0 do
begin
if Length(LowerCase(FSearchRec.Name)) = 16 then
begin
Handle := Fileopen(Dir + LowerCase(FSearchRec.Name), 0);
Time := FormatdateTime(Model, Filedatetodatetime(Filegetdate(Handle)));
Fileclose(Handle);
// Time := FormatdateTime(Model, FileDateToDateTime(FileAge(Dir + LowerCase(FSearchRec.Name))));
Volume := IntToStr(FileSizeByName(Dir + FSearchRec.Name));
FileList.Add(LowerCase(FSearchRec.Name) + ' Time:' + Time + ' FileSize:' + Volume);
end;
FindResult := FindNext(FSearchRec);
end;
FindClose(FSearchRec);
FindResult := FindFirst(Dir + '*.db', faAnyFile + faDirectory, FSearchRec);
while FindResult = 0 do
begin
if Length(LowerCase(FSearchRec.Name)) = 17 then
begin
Handle := Fileopen(Dir + LowerCase(FSearchRec.Name), 0);
Time := FormatdateTime(Model, Filedatetodatetime(Filegetdate(Handle)));
Fileclose(Handle);
// Time := FormatdateTime(Model, FileDateToDateTime(FileAge(Dir + LowerCase(FSearchRec.Name))));
Volume := IntToStr(FileSizeByName(Dir + FSearchRec.Name));
FileList.Add(LowerCase(FSearchRec.Name) + ' Time:' + Time + ' FileSize:' + Volume);
end;
FindResult := FindNext(FSearchRec);
end;
Form1.ListBox1.Items := FileList;
except
Form1.BackTime.Enabled := False;
writeWorkLog('错误:#300001');//自己写的日志,记录错误出现的时间。
end;
FindClose(FSearchRec);
FileList.Free;
end;
TThread.CreateAnonymousThread(
procedure
begin
StatusBar1.Panels[0].Text := '开始下载...';
BitBtn1.Enabled := False;
BitBtn2.Enabled := False;
if DownloadFile(Dourl, lj1 + '\Temp.zip') then
begin
StatusBar1.Panels[0].Text := '下载完成...';
zip := TZipFile.Create;
zip.Open(lj1 + '\Temp.zip', TZipMode.zmRead);
zip.ExtractAll(lj1 + '\');
zip.Free;
DeleteFile(lj1 + '\Temp.zip');
StatusBar1.Panels[0].Text := StatusBar1.Panels[0].Text + ' steamcmd.exe 解压完成!';
BitBtn1.Enabled := True;
BitBtn2.Enabled := True;
end
else
begin
StatusBar1.Panels[0].Text := 'steamcmd.zip 下载失败!';
end;
if not SFindProcess('steamcmd.exe') then
begin
InstaUpdaSe;
InstaTime.Enabled := True;
IUName := 1;
end;
end).Start;