toob
Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору НЕ ПОМОГЛО даже удаление всего блока Цитата: -------------------------------------------------------------------------------- -- OnBeforeSave(filename) -- -- keep the number of backups as defined by backup.files = ? by Jos van der Zande (Jos) -- -- AutoItTools.OnBeforeSave -------------------------------------------------------------------------------- function AutoItTools:shok:nBeforeSave(filename) -- skip making the backup when file isn't changed if not editor.Modify then return false end local backupfiles = tonumber(props['backup.files']) -- backup specified and bigger than 0 ? if backupfiles == nil or backupfiles == 0 then return false end -- get file directory fdir = filename:match(".+[/\\]") fname = filename:match(".+[/\\](.+)") fext = fname:match(".+(%..+)") or "" if fext ~= "" then fname = fname:match("(.+)%..+") end -- set backup directory if props['backup.directory'] == "" then bdir = fdir .. "backup" -- no fixed backupdirectory location defined else bdir = props['backup.directory'] -- use the backupdirectory location defined for backup.directory end -- set backup rename to extra string. default Filename_bakx.Fileext if props['backup.renameto'] == "" then bmid = "_bak" -- default else bmid = props['backup.renameto'] -- use the backupdirectory location defined for backup.directory end -- ensure the backup directory exists perform_oscommand('mkdir "'..bdir..'"') -- -- check for all current existing backup files local currentbackupfiles = 1 local tfile = "" local fh=0 while (1) do tfile = bdir.."\\".. fname..bmid..currentbackupfiles..fext tfile2 = bdir.."\\".. fname..bmid..string.format("%02d",currentbackupfiles)..fext fh = io.open (tfile, "r") if fh == nil then fh = io.open (tfile2, "r") if fh == nil then break end io.close(fh) else io.close(fh) os.rename (tfile,tfile2) end currentbackupfiles = currentbackupfiles + 1 end -- move old backupfiles to 1 to (backupfiles-1) if backupfiles > 0 and backupfiles < currentbackupfiles then for y=1,currentbackupfiles-1 do y2 = y + backupfiles - currentbackupfiles local fn1 = bdir.."\\".. fname..bmid..string.format("%02d",y)..fext local fn2 = bdir.."\\".. fname..bmid..string.format("%02d",y2)..fext if currentbackupfiles - y < backupfiles then os.remove (fn2) os.rename (fn1,fn2) else os.remove (fn1) end end currentbackupfiles = backupfiles end local fn1 = bdir.."\\"..fname..bmid..string.format("%02d",currentbackupfiles)..fext os.remove (fn1) os.rename (filename, fn1) return false end |
| Всего записей: 381 | Зарегистр. 20-05-2008 | Отправлено: 01:17 05-05-2022 | Исправлено: toob, 02:56 07-05-2022 |
|