249 posts
Location
In the universe
Posted 08 October 2012 - 11:58 PM
It is there any possible ways to change a file so it can only be Read-Only and it can't be modified?
Thanks :D/>/>
231 posts
Posted 09 October 2012 - 12:02 AM
You could modify the functions of the fs API (during runtime) to act as if the file was read only.
For example:
readOnly = {"file/I/want/to/be/read/only" = true, "another/file" = true}
local oldFS = fs
fs.open = function(filename, mode)
if readOnly[filename] and (mode == "w" or mode == "wb" or mode =="a" or mode == "ab") then
return nil
else
return oldFS.open(filename, mode)
end
end
249 posts
Location
In the universe
Posted 09 October 2012 - 12:19 AM
so I need to paste that in my file?
231 posts
Posted 09 October 2012 - 12:23 AM
You need to write a version of every fs function that is affected by read-only files (open, isReadOnly, copy, and delete)
249 posts
Location
In the universe
Posted 09 October 2012 - 12:28 AM
Where I write them?
231 posts
Posted 09 October 2012 - 12:49 AM
The files will be made read-only when the code runs, so if you want them to be read only all the time, you should put it in your startup file.