i was wondering how to make a file
to
fs.isReadOnly()
but is that possible Without wditing bios/ shell ?
thanks in advance
-mikk809h
local file = fs.open(someFilePath, 'a')
if not file then
print 'File is read only'
else
print 'File is writable'
file.close()
end
local oldFsOpen = fs.open
fs.open = function({...})
if args[1] == "/startup" or "startup" then
print("Not allowed")
else
oldFsOpen(args)
end
end
you can still override this with io.open, you would have to override io.open as fs wraps around io doesn't it???You will have to over-write the FS lib to do it. That is the only way I can think of.local oldFsOpen = fs.open fs.open = function({...}) if args[1] == "/startup" or "startup" then print("Not allowed") else oldFsOpen(args) end end
Just modify my code and expand it to fit your needs.well.. i have to make 2 specific codes, now? one for FS and one for IO ???
local oldFsOpen = fs.open
local args = {}
fs.open = function()
if args[1] == "/hel" or "hel" then
print("Not allowed")
else
oldFsOpen(args)
end
end
"broke" = that if i type in any programs that EXISTS, then it prints Not Allowed :o/>
if args[1] == "/hel" or args[1] == "hel" then
also you do not set args{}
local oldFsOpen = fs.open
fs.open = function(...)
local tArgs = {...}
if tArgs[1] == "/startup" or "startup" then
print("Not allowed")
else
oldFsOpen(args)
end
end
you forgot to define args proprely
local oldFsOpen = fs.open
fs.open = function(...)
local tArgs = {...}
if tArgs[1] == "/startup" or "startup" then
print("Not allowed")
else
oldFsOpen(args)
end
end
local oldFsOpen = fs.open
fs.open = function(...)
local tArgs = {...}
if tArgs[1] == "/startup" or tArgs[1] == "startup" then
print("Not allowed")
else
return oldFsOpen(unpack(tArgs))
end
end
error("Access denied.",2)
local oldFsOpen = fs.open
fs.open = function(...)
local tArgs = {...}
local lockFiles = {
"startup",
"/startup",
"update",
"/update",
"pass",
"/pass",
"/.@main@./config.cfg",
".@main@./config.cfg",
"/.@main@./passwordSys",
".@main@./passwordSys",
".@main@./version.ver",
"/.@main@./version.ver",
".@main@./Uninstall",
"/.@main@./Uninstall",
".@main@./update",
"/.@main@./update",
".@main@./animations/LockTF",
"/.@main@./animations/LockTF",
".@main@./animations/Uninstall",
"/.@main@./animations/Uninstall",
".@main@./animations/download",
"/.@main@./animations/download",
".@main@./updater/update",
"/.@main@./updater/update"
}
if tArgs[1] == #lockFiles then
error("Access denied!", 2)
else
return oldFsOpen(unpack(tArgs))
end
end