Skip to content

Files

Latest commit

 

History

History

file

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 15, 2017
Feb 23, 2017
Jan 23, 2017
Mar 12, 2017
Sep 14, 2018
Aug 29, 2018
Sep 18, 2018
May 13, 2019
May 29, 2017
Sep 21, 2018
Sep 12, 2016
Sep 14, 2018
Sep 12, 2016
Sep 14, 2018

mach.io.file

This package provides functionality for dealing with the file system.

mach.io.file.file

This module is deprecated. Please use mach.io.file.path instead.

mach.io.file.path

The Path type may be used to perform actions and manipulations with file paths. An instance should be created by calling the constructor with some string representing a file path.

import mach.range : tailis;
auto path = Path(__FILE_FULL_PATH__); // .../mach/io/file/path.d
assert(path.exists); // Refers to an actual file or directory?
assert(path.isfile); // It's a file,
assert(!path.isdir); // It's not a directory,
assert(!path.islink); // Nor is it a symbolic link.
assert(path.basename == "path.d"); // Get the file name
assert(path.directory.tailis("file")); // Get the directory, .../mach/io/file
assert(path.extension == "d"); // Get the file extension
assert(path.stripext.tailis("path")); // Get the path without the extension
assert(path.filesize > 100); // Get the file size in bytes

Also supported are copy, rename, and remove methods.

auto path = Path(__FILE_FULL_PATH__); // .../mach/io/file/path.d
auto copy = path.copy(path ~ ".unittest.copied");
auto renamed = copy.rename(path ~ ".unittest.renamed");
renamed.remove();
assert(!renamed.exists);