Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function securePaths()
- del = 0
- local lockedFiles = {"startup", ".advLock"}
- local oldFsDelete = fs.delete
- fs.delete = function(...)
- local tArg = {...}
- if not fs.isLocked then
- return oldFsDelete(unpack(tArg))
- end
- for lockedFile = 1, #lockedFiles do
- if string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and not fs.isDir(tArg[1]) then
- error("AdvLock: You do not have access to delete this file!", 3)
- elseif string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and fs.isDir(tArg[1]) then
- error("AdvLock: You do not have access to delete this folder!", 3)
- else
- del = del + 1
- end
- end
- if del == #lockedFiles then
- del = 0
- return oldFsDelete(unpack(tArg))
- end
- end
- del = 0
- local oldFsOpen = fs.open
- fs.open = function(...)
- local tArg = {...}
- if not fs.isLocked then
- return oldFsOpen(unpack(tArg))
- end
- for lockedFile = 1, #lockedFiles do
- if string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and not fs.isDir(tArg[1]) then
- error("AdvLock: You do not have access to edit this file!", 3)
- elseif string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and fs.isDir(tArg[1]) then
- error("AdvLock: You do not have access to edit this folder!", 3)
- else
- del = del + 1
- end
- end
- if del == #lockedFiles then
- del = 0
- return oldFsOpen(unpack(tArg))
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment