ComputerCraft icon indicating copy to clipboard operation
ComputerCraft copied to clipboard

Rewrite file systems to use ByteChannels

Open SquidDev opened this issue 5 years ago • 1 comments

This replaces the existing IMount openFor* method with openChannelFor* ones, which return an appropriate byte channel instead. I've put a little more detail in the commit message about the implications of this, but there's a couple of user-facing benefits:

  • Add support for seekable handles. This works for any main filesystem or HTTP handle opened in binary mode.
  • Rewrite the io library to more accurately emulate PUC Lua's implementation. This passes a large portion of the the test suite - the remaining issues mainly involve their use of os.date and setvbuf, neither of which are implemented.

SquidDev avatar Sep 21 '18 15:09 SquidDev

Possibly worth noting that seekable binary handles do not work for Jar mounts - namely the rom and any treasure disks.

It would be possible to implement this by reading the entire contents of the file into memory and exposing it as an ArrayByteChannel, but I think it's worth discussing whether it's worth it.

SquidDev avatar Nov 03 '18 15:11 SquidDev