更新FileMgr.dll,优化创建目录逻辑

This commit is contained in:
zhangzhanhong 2022-01-13 13:37:13 +08:00
parent 61a7287932
commit 2e099473c0
4 changed files with 20 additions and 14 deletions

View File

@ -1,7 +1,7 @@
FTP数据备份工具
<h1>FTP数据备份工具</h1>
使用步骤:
1、TsFTP目录放入解释器所在目录的funcext中
2、可选修改默认配置信息TsFTP\TsFTPBackupConfig.tsf
3、参考examples\example1.tsl编写备份脚本
4、可选添加备份脚本的定时调度。
使用步骤:
1、TsFTP目录放入解释器所在目录的funcext中更新替换plugin\FileMgr.dll
2、可选修改默认配置信息TsFTP\TsFTPBackupConfig.tsf
3、参考examples\example1.tsl编写备份脚本
4、可选添加备份脚本的定时调度。

View File

@ -19,7 +19,7 @@ Type TsFTPBackup = Class
Begin
if not Host then Host := defaultConfig['Host'];
if not port then port := defaultConfig['Port'];
if not port then port := 21;
if not port then port := 990;
if not username then username := defaultConfig['username'];
if not password then password := defaultConfig['password'];
if not initFtpObj() then return 0;
@ -48,14 +48,14 @@ Type TsFTPBackup = Class
Begin
path := ExtractFilePath(src);
files := filelist('',src);
try
ftpObj.MakeDir(destPath);
except
end;
for j,f in files do begin
if f['FileName']='.' or f['FileName']='..' then continue;
if pos('D',f['Attr']) then begin
if recursive then begin
try
ftpObj.MakeDir(destPath+f['FileName']+'/');
except
end;
backupPath(path+'\\'+f['FileName']+"\\*",destPath+f['FileName']+'/',recursive);
end;
end else if f['Attr']='A' then begin
@ -100,7 +100,13 @@ Type TsFTPBackup = Class
return 2;
end;
st_put:=CreateObject("TFileStream","",srcfile,0);
ret := ftpObj.Put(st_put,destfile,0);
try
ret := ftpObj.Put(st_put,destfile,0);
except
msg := '源文件('+srcfile+')->目标文件('+destfile+')上传失败。';
log(msg,'error');
return 0;
end;
size_d := ftpObj.Size(destfile);
if size_s=size_d then begin
msg := '源文件('+srcfile+')->目标文件('+destfile+')上传成功。';

View File

@ -1,8 +1,8 @@
Function TsFTPBackupConfig();
Begin
return array(
'Host':'192.168.0.1',
'Port':21,
'Host':'192.168.104.42',
'Port':990,
'username':'',
'password':'',
'logPath':'',

BIN
plugin/FileMgr.dll Normal file

Binary file not shown.