2
0

BasicFile.lua 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. class "BasicFile"
  2. function BasicFile:__getvar(name)
  3. if name == "file" then
  4. local retVal = Polycode.BasicFile_get_file(self.__ptr)
  5. if retVal == nil then return nil end
  6. local __c = _G["FILE"]("__skip_ptr__")
  7. __c.__ptr = retVal
  8. return __c
  9. end
  10. end
  11. function BasicFile:__setvar(name,value)
  12. if name == "file" then
  13. Polycode.BasicFile_set_file(self.__ptr, value.__ptr)
  14. return true
  15. end
  16. return false
  17. end
  18. function BasicFile:read(ptr, size, count)
  19. local retVal = Polycode.BasicFile_read(self.__ptr, ptr.__ptr, size.__ptr, count.__ptr)
  20. return retVal
  21. end
  22. function BasicFile:write(ptr, size, count)
  23. local retVal = Polycode.BasicFile_write(self.__ptr, ptr.__ptr, size.__ptr, count.__ptr)
  24. return retVal
  25. end
  26. function BasicFile:seek(offset, origin)
  27. local retVal = Polycode.BasicFile_seek(self.__ptr, offset, origin)
  28. return retVal
  29. end
  30. function BasicFile:tell()
  31. local retVal = Polycode.BasicFile_tell(self.__ptr)
  32. return retVal
  33. end
  34. function BasicFile:__delete()
  35. if self then Polycode.delete_BasicFile(self.__ptr) end
  36. end