Scite 備份檔案 |
|
OnBeforeSave
且產生舊版檔案的備份內容。這個腳本使用簡單的迴圈來複製檔案內容,並不會呼叫外部指令去完整地複製原始檔案,不過它會失去自訂屬性與其他元資料。如果您需要完全的備份,建議您執行外部指令來進行完全複製。此腳本使用 SciteExtMan。
-- NOTE: uses extman.lua -- Limitations: silently fails, does not copy metadata local function backupDeFile(fname) local BLK = 1024 * 64 bkname = fname.."~" local inf = io.open(fname, "rb") local outf = io.open(bkname, "wb") if not inf or not outf then return end while true do local dat = inf:read(BLK) if not dat then break end outf:write(dat) end inf:close() outf:close() end scite_OnBeforeSave(backupDeFile)
-- KeinHongMan
如果您只要簡單的方法來備份目前檔案,您可以在 SciTEGlobal.properties 中新增下列內容。
command.name.1.*=Backup this file command.1.*=dostring os.execute("cmd /C copy $(FileNameExt?) $(FileName?)_"..os.date("%y%m%d%H%M")..".$(FileExt?)") command.mode.1.*=subsystem:lua,savebefore:no
-- Alan MN