immibis

web-vfs

Aug 4th, 2013
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. local fs_http = {
  2.     isReadOnly = function() return true end,
  3.     exists = function(self, path)
  4.         return http.get(self.base .. path:sub(1)) ~= nil
  5.     end,
  6.     open = function(self, path, mode)
  7.         assert(mode == "r", "HTTP FS only supports text reading!")
  8.         return http.get(self.base .. path:sub(1))
  9.     end,
  10.     list = function(self, path) return {} end,
  11.     getDrive = function(self) return self.base end,
  12. }
  13.  
  14. vfs.registerFS("http", function(mp, opts)
  15.     local t = {base = opts.base}
  16.     setmetatable(t, {__index = fs_http})
  17.     return t
  18. end)
  19.  
  20. --vfs.unmount("/web/")
  21. --vfs.mount("/web/", "http", {base="http://en.wikipedia.org/wiki/"})
Advertisement
Add Comment
Please, Sign In to add comment