2009/9/2 Tom Robinson <
tlrob...@gmail.com>:
> I went ahead and did this (and in the process finished the "output" half of
> BinaryIO. Though I'm not sure it's correct: input and output are completely
> independent)
> Currently parseMultipart takes a second "options" parameter, which if it
> contains a truthy "nodisk" it will return a ByteString in "tempfile" instead
> of a string containing the path of the temporary
> file. We'll probably want to change that. Also, we probably want to add some sort of configuration in Request to add that option.
> I haven't tested it extensively. We're still using Strings to pass around
> binary data within parseMultipart, which may be a problem. That function is
> a beast which needs to be rewritten.
I think the code is actually quite neat. It just highlights some
functionalty that may be missing from the binary and io modules. For
example, if it would be possible to search for multi-byte sequences
with ByteArray.indexOf, and ByteArray.decodeToString took optional
start and end argument to create a string from just a part of itself,
you could just stringify the header part of the buffer.
The next thing that strikes me is that you have to do a slice() to
write a part of a String or ByteArray. That write() method should
really take optional start and end arguments, too, and ByteArray
should have a method to copy or move bytes within itself or to other
ByteArrays, similar to Java's System.arraycopy. Then, once narwhal
implements IO.readInto(), you'll be able to implement this with a
single fixed-size ByteArray buffer :-)
I'm currently implementing file, io, and binary for Helma NG and
taking notes on any such things I find, and I'll post them to a wiki
page soon.
Hannes