Path.writeFile

Write data to file as is

struct Path
@safe const
void
writeFile
(
in void[] buffer
)

Parameters

buffer void[]

untypes array to write to file.

Throws

FileException in case of error

Examples

import dshould;
Path root = createTempPath();
scope(exit) root.remove();

root.join("test-write-1.txt").exists.should.be(false);
root.join("test-write-1.txt").writeFile("Hello world");
root.join("test-write-1.txt").exists.should.be(true);
root.join("test-write-1.txt").readFile.should.equal("Hello world");

ubyte[] data = [1, 7, 13, 5, 9];
root.join("test-write-2.txt").exists.should.be(false);
root.join("test-write-2.txt").writeFile(data);
root.join("test-write-2.txt").exists.should.be(true);
ubyte[] rdata = cast(ubyte[])root.join("test-write-2.txt").readFile;
rdata.length.should.equal(5);
rdata[0].should.equal(1);
rdata[1].should.equal(7);
rdata[2].should.equal(13);
rdata[3].should.equal(5);
rdata[4].should.equal(9);

Meta