NebulousLabs/Sia — pull request #210 by lukechampine (2014-08-29 20:29:29+00:00)
Title: siafiles

Just some useful file-related utilities. I wanted to replace the "os" import entirely, but that turned out to be trickier than anticipated. Maybe later.

*RSEncode:*
RSEncode now takes byte slices instead of io.Writers. This removes the need for painful interface conversions. We were just using `bytes.Buffer`s as writers anyway, so this isn't any less efficient.

Utilities:
- siafiles.ValidName() returns whether a string is a valid filename
- siafiles.Remove() is like `rm -f` (it does not return an error if the file does not exist)
- siafiles.Exists() returns whether a file exists.

Scratch:
The `scratch` type is a `bytes.Buffer` that can be saved to disk. A `PadTo()` function is also provided. This isn't terribly useful at the moment, since `bytes.Buffer` does not implement all of the interfaces that a standard `os.File` does, but it does clean up delta/update.go quite a bit. If it doesn't turn out to be useful elsewhere, I'll probably remove it and use an explicit `bytes.Buffer` in update.go.