append

Appends buffer to file name.

Creates the file if it does not already exist.

  1. void append(R name, void[] buffer)
    void
    append
    (
    R
    )
    (,
    const void[] buffer
    )
  2. void append(R name, void[] buffer)

Parameters

name R

string or range of characters representing the file name

buffer void[]

data to be appended to file

Throws

FileException on error.

Examples

scope(exit)
{
    assert(exists(deleteme));
    remove(deleteme);
}

int[] a = [ 0, 1, 1, 2, 3, 5, 8 ];
write(deleteme, a); // deleteme is the name of a temporary file
int[] b = [ 13, 21 ];
append(deleteme, b);
const bytes = read(deleteme);
const fileInts = () @trusted { return cast(int[]) bytes; }();
assert(fileInts == a ~ b);

Meta