Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open = function(name)
- local r
- if name then
- r = fs.open(name,"r")
- end
- local a = {}
- local i = 1
- for line in r.readLine do
- a[i] = line
- i = i + 1
- end
- a.readHandle = r
- a.fileName = name
- function a:close()
- for i = 1,#self do
- self[i] = nil
- end
- self["close"] = nil
- self["save"] = nil
- self["fileName"] = nil
- self["readHandle"] = nil
- end
- function a:update()
- if self.fileName then
- local r = fs.open(self.fileName,"r")
- local i = 1
- for line in r.readLine do
- self[i] = line
- i = i + 1
- end
- end
- end
- function a:save()
- if not self.fileName then
- return false
- end
- local w = fs.open(self.fileName,"w")
- for i=1,#self do
- if self[i] then
- w.writeLine(self[i])
- end
- end
- w.close()
- end
- if r then
- return a
- end
- end
Add Comment
Please, Sign In to add comment