Seekable
Seekable permits random access read and write
Patch
Examples of patching a file.
import scalax.io._
import java.io.File
// see codec example for why codec is required
implicit val codec = scalax.io.Codec.UTF8
val file: Seekable = Resource.fromFile(new File("file"))
// write "people" after character 6
// if the file is < 6 characters an underflow exception is thrown
// if the patch extends past the end of the file then the file is extended
// Note: If the offset is always dependent on the data being written
file.patch(6, "people",OverwriteAll)
file.patch(6, "people",OverwriteAll)(Codec.UTF8)
// patch the file with a traversable of bytes
// patch starts after 6th byte
file.patch(6, "people".getBytes,OverwriteAll)
// Overwrite only 2 bytes that are in the file.
// the extra bytes will be inserted
file.patch(2,List[Byte](1,2,3),OverwriteSome(2))