Thanks
[QUESTION] [LUA] How can I change a file to be Read-Only?
Started by anonimo182, Oct 08 2012 10:58 PM
5 replies to this topic
#1
Posted 08 October 2012 - 10: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
/>
Thanks
#2
Posted 08 October 2012 - 11:02 PM
You could modify the functions of the fs API (during runtime) to act as if the file was read only.
For example:
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
#3
Posted 08 October 2012 - 11:19 PM
so I need to paste that in my file?
#4
Posted 08 October 2012 - 11:23 PM
You need to write a version of every fs function that is affected by read-only files (open, isReadOnly, copy, and delete)
#5
Posted 08 October 2012 - 11:28 PM
Where I write them?
#6
Posted 08 October 2012 - 11:49 PM
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.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











