Revert using addresses in VFS back to using proxy objects, since I probably won't ever come around to actually implement mounts and symlinks being saved across reboots anyway. Closes #879.

This [partially] reverts commit 42040e2da654d23a74386c5f188aa0053646c100.

Conflicts:
	src/main/resources/assets/opencomputers/loot/OpenOS/lib/filesystem.lua
This commit is contained in:
Florian Nücke 2015-02-01 15:07:18 +01:00
parent e6668d59b4
commit 8092fae0a1

View File

@ -140,7 +140,7 @@ end
function filesystem.get(path) function filesystem.get(path)
local node, rest = findNode(path) local node, rest = findNode(path)
if node.fs then if node.fs then
local proxy = component.proxy(node.fs) local proxy = node.fs
path = "" path = ""
while node and node.parent do while node and node.parent do
path = filesystem.concat(node.name, path) path = filesystem.concat(node.name, path)
@ -192,7 +192,7 @@ function filesystem.mount(fs, path)
if vnode.fs then if vnode.fs then
return nil, "another filesystem is already mounted here" return nil, "another filesystem is already mounted here"
end end
vnode.fs = fs.address vnode.fs = fs
return true return true
end end
@ -218,7 +218,7 @@ function filesystem.mounts()
table.insert(queue, child) table.insert(queue, child)
end end
if node.fs then if node.fs then
return component.proxy(node.fs) or node.fs, path(node) return node.fs, path(node)
end end
end end
end end
@ -288,7 +288,7 @@ function filesystem.exists(path)
return true return true
end end
if node and node.fs then if node and node.fs then
return component.proxy(node.fs).exists(rest) return node.fs.exists(rest)
end end
return false return false
end end
@ -299,7 +299,7 @@ function filesystem.size(path)
return 0 -- virtual directory or symlink return 0 -- virtual directory or symlink
end end
if node.fs and rest then if node.fs and rest then
return component.proxy(node.fs).size(rest) return node.fs.size(rest)
end end
return 0 -- no such file or directory return 0 -- no such file or directory
end end
@ -310,7 +310,7 @@ function filesystem.isDirectory(path)
return true -- virtual directory return true -- virtual directory
end end
if node.fs then if node.fs then
return not rest or component.proxy(node.fs).isDirectory(rest) return not rest or node.fs.isDirectory(rest)
end end
return false return false
end end
@ -321,7 +321,7 @@ function filesystem.lastModified(path)
return 0 -- virtual directory return 0 -- virtual directory
end end
if node.fs and rest then if node.fs and rest then
return component.proxy(node.fs).lastModified(rest) return node.fs.lastModified(rest)
end end
return 0 -- no such file or directory return 0 -- no such file or directory
end end
@ -333,7 +333,7 @@ function filesystem.list(path)
end end
local result, reason local result, reason
if node and node.fs then if node and node.fs then
result, reason = component.proxy(node.fs).list(rest or "") result, reason = node.fs.list(rest or "")
end end
result = result or {} result = result or {}
if not vrest then if not vrest then
@ -367,7 +367,7 @@ function filesystem.makeDirectory(path)
end end
local node, rest = findNode(path) local node, rest = findNode(path)
if node.fs and rest then if node.fs and rest then
return component.proxy(node.fs).makeDirectory(rest) return node.fs.makeDirectory(rest)
end end
if node.fs then if node.fs then
return nil, "virtual directory with that name already exists" return nil, "virtual directory with that name already exists"
@ -393,7 +393,7 @@ function filesystem.remove(path)
local function removePhysical() local function removePhysical()
node, rest = findNode(path) node, rest = findNode(path)
if node.fs and rest then if node.fs and rest then
return component.proxy(node.fs).remove(rest) return node.fs.remove(rest)
end end
return false return false
end end
@ -417,8 +417,8 @@ function filesystem.rename(oldPath, newPath)
local oldNode, oldRest = findNode(oldPath) local oldNode, oldRest = findNode(oldPath)
local newNode, newRest = findNode(newPath) local newNode, newRest = findNode(newPath)
if oldNode.fs and oldRest and newNode.fs and newRest then if oldNode.fs and oldRest and newNode.fs and newRest then
if oldNode.fs == newNode.fs then if oldNode.fs.address == newNode.fs.address then
return component.proxy(oldNode.fs).rename(oldRest, newRest) return oldNode.fs.rename(oldRest, newRest)
else else
local result, reason = filesystem.copy(oldPath, newPath) local result, reason = filesystem.copy(oldPath, newPath)
if result then if result then
@ -465,7 +465,7 @@ end
function fileStream:close() function fileStream:close()
if self.handle then if self.handle then
component.proxy(self.fs).close(self.handle) self.fs.close(self.handle)
self.handle = nil self.handle = nil
end end
end end
@ -474,21 +474,21 @@ function fileStream:read(n)
if not self.handle then if not self.handle then
return nil, "file is closed" return nil, "file is closed"
end end
return component.proxy(self.fs).read(self.handle, n) return self.fs.read(self.handle, n)
end end
function fileStream:seek(whence, offset) function fileStream:seek(whence, offset)
if not self.handle then if not self.handle then
return nil, "file is closed" return nil, "file is closed"
end end
return component.proxy(self.fs).seek(self.handle, whence, offset) return self.fs.seek(self.handle, whence, offset)
end end
function fileStream:write(str) function fileStream:write(str)
if not self.handle then if not self.handle then
return nil, "file is closed" return nil, "file is closed"
end end
return component.proxy(self.fs).write(self.handle, str) return self.fs.write(self.handle, str)
end end
function filesystem.open(path, mode) function filesystem.open(path, mode)
@ -503,7 +503,7 @@ function filesystem.open(path, mode)
return nil, "file not found" return nil, "file not found"
end end
local handle, reason = component.proxy(node.fs).open(rest, mode) local handle, reason = node.fs.open(rest, mode)
if not handle then if not handle then
return nil, reason return nil, reason
end end
@ -512,8 +512,7 @@ function filesystem.open(path, mode)
local function cleanup(self) local function cleanup(self)
if not self.handle then return end if not self.handle then return end
local proxy = component.proxy(self.fs) pcall(self.fs.close, self.handle)
if proxy then pcall(proxy.close, self.handle) end
end end
local metatable = {__index = fileStream, local metatable = {__index = fileStream,
__gc = cleanup, __gc = cleanup,