OSFileEntry.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. class "OSFileEntry"
  2. TYPE_FILE = 0
  3. TYPE_FOLDER = 1
  4. function OSFileEntry:__index__(name)
  5. if name == "name" then
  6. retVal = Polycore.OSFileEntry_get_name(self.__ptr)
  7. if Polycore.__ptr_lookup[retVal] ~= nil then
  8. return Polycore.__ptr_lookup[retVal]
  9. else
  10. Polycore.__ptr_lookup[retVal] = Polycode::String("__skip_ptr__")
  11. Polycore.__ptr_lookup[retVal].__ptr = retVal
  12. return Polycore.__ptr_lookup[retVal]
  13. end
  14. elseif name == "extension" then
  15. retVal = Polycore.OSFileEntry_get_extension(self.__ptr)
  16. if Polycore.__ptr_lookup[retVal] ~= nil then
  17. return Polycore.__ptr_lookup[retVal]
  18. else
  19. Polycore.__ptr_lookup[retVal] = Polycode::String("__skip_ptr__")
  20. Polycore.__ptr_lookup[retVal].__ptr = retVal
  21. return Polycore.__ptr_lookup[retVal]
  22. end
  23. elseif name == "nameWithoutExtension" then
  24. retVal = Polycore.OSFileEntry_get_nameWithoutExtension(self.__ptr)
  25. if Polycore.__ptr_lookup[retVal] ~= nil then
  26. return Polycore.__ptr_lookup[retVal]
  27. else
  28. Polycore.__ptr_lookup[retVal] = Polycode::String("__skip_ptr__")
  29. Polycore.__ptr_lookup[retVal].__ptr = retVal
  30. return Polycore.__ptr_lookup[retVal]
  31. end
  32. elseif name == "basePath" then
  33. retVal = Polycore.OSFileEntry_get_basePath(self.__ptr)
  34. if Polycore.__ptr_lookup[retVal] ~= nil then
  35. return Polycore.__ptr_lookup[retVal]
  36. else
  37. Polycore.__ptr_lookup[retVal] = Polycode::String("__skip_ptr__")
  38. Polycore.__ptr_lookup[retVal].__ptr = retVal
  39. return Polycore.__ptr_lookup[retVal]
  40. end
  41. elseif name == "fullPath" then
  42. retVal = Polycore.OSFileEntry_get_fullPath(self.__ptr)
  43. if Polycore.__ptr_lookup[retVal] ~= nil then
  44. return Polycore.__ptr_lookup[retVal]
  45. else
  46. Polycore.__ptr_lookup[retVal] = Polycode::String("__skip_ptr__")
  47. Polycore.__ptr_lookup[retVal].__ptr = retVal
  48. return Polycore.__ptr_lookup[retVal]
  49. end
  50. elseif name == "type" then
  51. return Polycore.OSFileEntry_get_type(self.__ptr)
  52. end
  53. end
  54. function OSFileEntry:__set_callback(name,value)
  55. if name == "type" then
  56. Polycore.OSFileEntry_set_type(self.__ptr, value)
  57. return true
  58. end
  59. return false
  60. end
  61. function OSFileEntry:OSFileEntry(...)
  62. for k,v in pairs(arg) do
  63. if type(v) == "table" then
  64. if v.__ptr ~= nil then
  65. arg[k] = v.__ptr
  66. end
  67. end
  68. end
  69. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  70. self.__ptr = Polycore.OSFileEntry(unpack(arg))
  71. Polycore.__ptr_lookup[self.__ptr] = self
  72. end
  73. end
  74. function OSFileEntry:__delete()
  75. Polycore.__ptr_lookup[self.__ptr] = nil
  76. Polycore.delete_OSFileEntry(self.__ptr)
  77. end