Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local FILE_TO_PROTECT = shell.resolve ("/startup")
- local old_fsOpen = _G["fs"]["open"]
- local old_fsDelete = _G["fs"]["delete"]
- local old_fsIsReadOnly = _G["fs"]["isReadOnly"]
- -- Override of fs.open.
- _G["fs"]["open"] = function (path, mode)
- path = shell.resolve (path)
- mode = string.lower (mode)
- if path == FILE_TO_PROTECT then
- return nil
- end
- return old_fsOpen (path, mode)
- end
- -- Override of fs.delete.
- _G["fs"]["delete"] = function (path)
- path = shell.resolve (path)
- if path == FILE_TO_PROTECT then
- -- Mimick error.
- return shell.run ("delete", "/rom/")
- end
- return old_fsDelete (path)
- end
- -- Override of fs.isReadOnly.
- _G["fs"]["isReadOnly"] = function (path)
- path = shell.resolve (path)
- if path == FILE_TO_PROTECT then
- return true
- end
- return old_fsIsReadOnly (path)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement