Path.getSize

Return size of file specified by path

struct Path
@safe const
ulong
getSize
()

Examples

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

ubyte[4] data = [1, 2, 3, 4];
root.join("test-file.txt").writeFile(data);
root.join("test-file.txt").getSize.should.equal(4);

version(Posix) {
    // Prepare test dir in user's home directory
    Path home_tmp = createTempPath("~", "tmp-d-test");
    scope(exit) home_tmp.remove();
    string tmp_dir_name = home_tmp.baseName;

    Path("~/%s/test-file.txt".format(tmp_dir_name)).writeFile(data);
    Path("~/%s/test-file.txt".format(tmp_dir_name)).getSize.should.equal(4);
}

Meta