BasicFileProvider.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. class "BasicFileProvider"
  2. function BasicFileProvider:BasicFileProvider(...)
  3. local arg = {...}
  4. for k,v in pairs(arg) do
  5. if type(v) == "table" then
  6. if v.__ptr ~= nil then
  7. arg[k] = v.__ptr
  8. end
  9. end
  10. end
  11. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  12. self.__ptr = Polycore.BasicFileProvider(unpack(arg))
  13. end
  14. end
  15. function BasicFileProvider:openFile(fileName, opts)
  16. local retVal = Polycore.BasicFileProvider_openFile(self.__ptr, fileName, opts)
  17. if retVal == nil then return nil end
  18. local __c = _G["Polycode::CoreFile"]("__skip_ptr__")
  19. __c.__ptr = retVal
  20. return __c
  21. end
  22. function BasicFileProvider:closeFile(file)
  23. local retVal = Polycore.BasicFileProvider_closeFile(self.__ptr, file.__ptr)
  24. end
  25. function BasicFileProvider:addSource(source)
  26. local retVal = Polycore.BasicFileProvider_addSource(self.__ptr, source)
  27. end
  28. function BasicFileProvider:removeSource(source)
  29. local retVal = Polycore.BasicFileProvider_removeSource(self.__ptr, source)
  30. end
  31. function BasicFileProvider:__delete()
  32. if self then Polycore.delete_BasicFileProvider(self.__ptr) end
  33. end