file.bmx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ' Copyright (c) 2016-2022 Bruce A Henderson
  2. '
  3. ' This software is provided 'as-is', without any express or implied
  4. ' warranty. In no event will the authors be held liable for any damages
  5. ' arising from the use of this software.
  6. '
  7. ' Permission is granted to anyone to use this software for any purpose,
  8. ' including commercial applications, and to alter it and redistribute it
  9. ' freely, subject to the following restrictions:
  10. '
  11. ' 1. The origin of this software must not be misrepresented; you must not
  12. ' claim that you wrote the original software. If you use this software
  13. ' in a product, an acknowledgment in the product documentation would be
  14. ' appreciated but is not required.
  15. '
  16. ' 2. Altered source versions must be plainly marked as such, and must not be
  17. ' misrepresented as being the original software.
  18. '
  19. ' 3. This notice may not be removed or altered from any source
  20. ' distribution.
  21. '
  22. SuperStrict
  23. Import "common.bmx"
  24. Type TStreamFile
  25. Field filePtr:Byte Ptr
  26. Field stream:TStream
  27. Method Create:TStreamFile(stream:TStream)
  28. filePtr = bmx_soloud_streamfile_new(Self)
  29. Self.stream = stream
  30. stream.Seek(0)
  31. Return Self
  32. End Method
  33. Function _eof:Int(sf:TStreamFile) { nomangle }
  34. Return sf.stream.Eof()
  35. End Function
  36. Function _seek(sf:TStreamFile, offset:Int) { nomangle }
  37. sf.stream.Seek(offset)
  38. End Function
  39. Function _length:Int(sf:TStreamFile) { nomangle }
  40. Return sf.stream.Size()
  41. End Function
  42. Function _pos:Int(sf:TStreamFile) { nomangle }
  43. Return sf.stream.Pos()
  44. End Function
  45. Function _read:Int(sf:TStreamFile, dst:Byte Ptr, size:Int) { nomangle }
  46. Return sf.stream.Read(dst, size)
  47. End Function
  48. Method Free()
  49. If filePtr Then
  50. bmx_soloud_streamfile_free(filePtr)
  51. filePtr = Null
  52. End If
  53. End Method
  54. End Type