#!/usr/bin/env dub
/+ dub.sdl:
name "recovery-storage-fault-probe"
targetPath "../../../build"
dependency "sparkles:base" path="../../.."
dependency "sparkles:event-horizon-sys" path="../../.."
dependency "sparkles:recovery" path="../../.."
dependency "sparkles:test-utils" path="../../.."
dflags "-preview=in" "-preview=dip1000"
buildType "checked" {
buildOptions "optimize" "inline" "debugInfo"
}
+/
/// A child process for strace syscall-fault injection; asserts forbidden destination writes.
module (module) storage_fault_probeA child process for strace syscall-fault injection; asserts forbidden destination writes.
storage_fault_probe;
import (package) stdstd.(package) std.algorithmalgorithm.(module) std.algorithm.searchingThis is a submodule of std.algorithm.
It contains generic searching algorithms.
Function Name Description all all!"a > 0"([1, 2, 3, 4]) returns true because all elements are positive any any!"a > 0"([1, 2, -3, -4]) returns true because at least one element is positive balancedParens balancedParens("((1 + 1) / 2)", '(', ')') returns true because the string has balanced parentheses. boyerMooreFinder find("hello world", boyerMooreFinder("or")) returns "orld" using the Boyer-Moore algorithm. canFind canFind("hello world", "or") returns true. count Counts all elements or elements matching a predicate, specific element or sub-range.
count([1, 2, 1]) returns 3,
count([1, 2, 1], 1) returns 2 and
count!"a < 0"([1, -3, 0]) returns 1. |
| countUntil | countUntil(a, b) returns the number of steps taken in a to reach b; for example, countUntil("hello!", "o") returns 4. |
| commonPrefix | commonPrefix("parakeet", "parachute") returns "para". |
| endsWith | endsWith("rocks", "ks") returns true. |
| extrema | extrema([2, 1, 3, 5, 4]) returns [1, 5]. |
| find | find("hello world", "or") returns "orld" using linear search. (For binary search refer to SortedRange.) |
| findAdjacent | findAdjacent([1, 2, 3, 3, 4]) returns the subrange starting with two equal adjacent elements, i.e. [3, 3, 4]. |
| findAmong | findAmong("abcd", "qcx") returns "cd" because 'c' is among "qcx". |
| findSkip | If a = "abcde", then findSkip(a, "x") returns false and leaves a unchanged, whereas findSkip(a, "c") advances a to "de" and returns true. |
| findSplit | findSplit("abcdefg", "de") returns a tuple of three ranges "abc", "de", and "fg". |
| findSplitAfter | findSplitAfter("abcdefg", "de") returns a tuple of two ranges "abcde" and "fg". |
| findSplitBefore | findSplitBefore("abcdefg", "de") returns a tuple of two ranges "abc" and "defg". |
| minCount | minCount([2, 1, 1, 4, 1]) returns tuple(1, 3). |
| maxCount | maxCount([2, 4, 1, 4, 1]) returns tuple(4, 2). |
| minElement | Selects the minimal element of a range. minElement([3, 4, 1, 2]) returns 1. |
| maxElement | Selects the maximal element of a range. maxElement([3, 4, 1, 2]) returns 4. |
| minIndex | Index of the minimal element of a range. minIndex([3, 4, 1, 2]) returns 2. |
| maxIndex | Index of the maximal element of a range. maxIndex([3, 4, 1, 2]) returns 1. |
| minPos | minPos([2, 3, 1, 3, 4, 1]) returns the subrange [1, 3, 4, 1], i.e., positions the range at the first occurrence of its minimal element. |
| maxPos | maxPos([2, 3, 1, 3, 4, 1]) returns the subrange [4, 1], i.e., positions the range at the first occurrence of its maximal element. |
| skipOver | Assume a = "blah". Then skipOver(a, "bi") leaves a unchanged and returns false, whereas skipOver(a, "bl") advances a to refer to "ah" and returns true. |
| startsWith | startsWith("hello, world", "hello") returns true. |
| until | Lazily iterates a range until a specific value is found. |
Source
std/algorithm/searching.d
searching : (alias template) storage_fault_probe.startsWith = std.algorithm.searching.startsWith(alias pred = (a, b) => a == b, Range, Needles...)(Range doesThisStart, Needles withOneOfThese) if (isInputRange!Range && (Needles.length > 1) && allSatisfy!(canTestStartsWith!(pred, Range), Needles))Checks whether the given
input range starts with (one
of) the given needle(s) or, if no needles are given,
if its front element fulfils predicate pred.
For more information about pred see find.
startsWith;
import (package) stdstd.(module) std.fileUtilities for manipulating files and scanning directories. Functions
in this module handle files as a unit, e.g., read or write one file
at a time. For opening files and manipulating them via handles refer
to module std.stdio.
Category Functions General exists isDir isFile isSymlink rename thisExePath Directories chdir dirEntries getcwd mkdir mkdirRecurse rmdir rmdirRecurse tempDir Files append copy read readText remove slurp write Symlinks symlink readLink Attributes attrIsDir attrIsFile attrIsSymlink getAttributes getLinkAttributes getSize setAttributes Timestamp getTimes getTimesWin setTimes timeLastModified timeLastAccessed timeStatusChanged Other DirEntry FileException PreserveAttributes SpanMode getAvailableDiskSpace
Source
std/file.d
file : (alias template) storage_fault_probe.exists = std.file.exists(R)(R name) if (isSomeFiniteCharInputRange!R && !isConvertibleToString!R)Determine whether the given file (or directory) exists.
exists, (alias template) storage_fault_probe.readText = std.file.readText(S = string, R)(auto ref R name) if (isSomeString!S && (isSomeFiniteCharInputRange!R || is(StringTypeOf!R)))Reads and validates (using validate) a text file. S can be
an array of any character type. However, no width or endian conversions are
performed. So, if the width or endianness of the characters in the given
file differ from the width or endianness of the element type of S, then
validation will fail.
readText;
import (package) stdstd.(module) std.pathThis module is used to manipulate path strings.
All functions, with the exception of expandTilde (and in some
cases absolutePath and relativePath), are pure
string manipulation functions; they don't depend on any state outside
the program, nor do they perform any actual file system actions.
This has the consequence that the module does not make any distinction
between a path that points to a directory and a path that points to a
file, and it does not know whether or not the object pointed to by the
path actually exists in the file system.
To differentiate between these cases, use isDir and
exists.
Note that on Windows, both the backslash (\) and the slash (/)
are in principle valid directory separators. This module treats them
both on equal footing, but in cases where a new separator is
added, a backslash will be used. Furthermore, the buildNormalizedPath
function will replace all slashes with backslashes on that platform.
In general, the functions in this module assume that the input paths
are well-formed. (That is, they should not contain invalid characters,
they should follow the file system's path format, etc.) The result
of calling a function on an ill-formed path is undefined. When there
is a chance that a path or a file name is invalid (for instance, when it
has been input by the user), it may sometimes be desirable to use the
isValidFilename and isValidPath functions to check
this.
Most functions do not perform any memory allocations, and if a string is
returned, it is usually a slice of an input string. If a function
allocates, this is explicitly mentioned in the documentation.
Category Functions Normalization absolutePath asAbsolutePath asNormalizedPath asRelativePath buildNormalizedPath buildPath chainPath expandTilde Partitioning baseName dirName dirSeparator driveName pathSeparator pathSplitter relativePath rootName stripDrive Validation isAbsolute isDirSeparator isRooted isValidFilename isValidPath Extension defaultExtension extension setExtension stripExtension withDefaultExtension withExtension Other filenameCharCmp filenameCmp globMatch CaseSensitive
Source
std/path.d
path : (alias template) storage_fault_probe.baseName = std.path.baseName(R)(return scope R path) if (isRandomAccessRange!R && hasSlicing!R && isSomeChar!(ElementType!R) && !isSomeString!R)Note
This function only strips away the specified suffix, which
doesn't necessarily have to represent an extension.
To remove the extension from a path, regardless of what the extension
is, use stripExtension.
To obtain the filename without leading directories and without
an extension, combine the functions like this:
assert(baseName(stripExtension("dir/file.ext")) == "file");
baseName, (alias template) storage_fault_probe.buildPath = std.path.buildPath(Range)(scope Range segments) if (isInputRange!Range && !isInfinite!Range && isSomeString!(ElementType!Range))Combines one or more path segments.
This function takes a set of path segments, given as an input
range of string elements or as a set of string arguments,
and concatenates them with each other. Directory separators
are inserted between segments if necessary. If any of the
path segments are absolute (as defined by isAbsolute), the
preceding segments will be dropped.
On Windows, if one of the path segments are rooted, but not absolute
(e.g. \foo), all preceding path segments down to the previous
root will be dropped. (See below for an example.)
This function always allocates memory to hold the resulting path.
The variadic overload is guaranteed to only perform a single
allocation, as is the range version if paths is a forward
range.
buildPath, (alias template) storage_fault_probe.dirName = std.path.dirName(R)(return scope R path) if (isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) && !isSomeString!R)Returns the parent directory of path. On Windows, this
includes the drive letter if present. If path is a relative path and
the parent directory is the current working directory, returns ".".
dirName;
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) storage_fault_probe.writeln = std.stdio.writeln(T...)(T args)Equivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln;
import (package) sparklessparkles.(package) sparkles.basebase.(module) sparkles.base.vfsThe capability VFS: a file-system interface over directory handles.
A program is given open directory handles instead of path strings and names
every file relative to one of them, so code holding a handle cannot reach
anything outside that directory, even while another process renames entries
or plants symbolic links inside it. Each handle carries rights checked at
compile time, which can be narrowed but never widened.
Specified in docs/specs/base/vfs/SPEC.md.
vfs : (enum) sparkles.base.vfs.types.AtomicDispositionWhat writeFileAtomic does about an entry already at the name (VFO9).
AtomicDisposition, (struct) sparkles.base.vfs.types.AtomicModeAn atomic write's mode (VFO9). Like OpenMode, a template argument of
writeFileAtomic, so the rights it needs are checked at compile time.
AtomicMode, (struct) sparkles.base.vfs.types.AtomicReceiptWhat a committed atomic write reports beyond the commit itself (VFO9).
Examples
static assert(AtomicMode.replace.rights == (Rights.create | Rights.write | Rights.rename));
enum keeping = AtomicMode(AtomicDisposition.replace, keepPermissions: true);
static assert(hasRights(keeping.rights, Rights.stat));
AtomicReceipt, (alias template) storage_fault_probe.IoResult = sparkles.base.io.errors.IoResult(T)The result of every I/O operation.
IoResult, (enum) sparkles.base.vfs.types.RightsThe operations a handle permits (VFH4). Rights are part of a handle's type, so
an operation whose right is absent does not compile (VFH6), and a derived
handle can only have fewer (VFH5).
Rights,
(alias) storage_fault_probe.ambientAuthority = sparkles.base.vfs.handles.AmbientAuthority sparkles.base.vfs.handles.ambientAuthority() pure nothrow @nogc @safeThe token openRoot requires (VFH7). Only ``ambientAuthority() makes one, so
searching for that name finds every place that creates authority from a path.
ambientAuthority, (alias template) storage_fault_probe.openRoot = sparkles.base.vfs.handles.openRoot(Rights R, V)(V* vfs, scope const(char)[] path, AmbientAuthority authority, ResolvePolicy policy = ResolvePolicy.init, CreateDefault create = CreateDefault.shared_, bool requireKernel = false) if (isVfs!V)Opens the directory path as a root with rights R (VFH7). The only
operation that resolves a path from the process root or current directory,
and the only one that follows symbolic links in the path it is given.
openRoot;
import (package) sparklessparkles.(package) sparkles.event_horizonevent_horizon.(package) sparkles.event_horizon.syssys.(module) sparkles.event_horizon.sys.vfsBlockingVfs: the capability VFS's blocking backend (VFB4), one blocking
system call per primitive, relative to the parent handle.
On POSIX the primitives are the *at family, never following the named entry
(VFN9). Directories a walk passes through are opened for search only where
the platform can (VFN14). Linux resolves whole paths with openat2(2) and
macOS with O_NOFOLLOW_ANY where the policy allows (VFN5); each probe's
absence is cached for the process, its presence never (VFN3), and a race the
kernel reports is retried up to the limit (VFN4).
Specified in docs/specs/base/vfs/backends.md.
vfs : (struct) sparkles.event_horizon.sys.vfs.BlockingVfsThe blocking backend over POSIX system calls.
BlockingVfs;
import (package) sparklessparkles.(package) sparkles.recoveryrecovery.(module) sparkles.recovery.archiveNumbered immutable generation files in a recovery archive.
A generation is one opaque payload under a canonical name: 20 decimal digits
and the layout's suffix (00000000000000000007.session). An append never
replaces a file: it is a create-only atomic write through the capability VFS
that syncs the directory (VFO9), so an earlier generation stays readable
until a newer one is durably acknowledged. Reads accept only a regular file,
never through a link (VFO12). Pruning keeps the newest valid generations at
or below an acknowledged cutoff and leaves damaged, unsupported, linked and
newer entries alone. A retirement marker records that a generation was
adopted elsewhere without touching its bytes.
archive : (alias) storage_fault_probe.appendGeneration = sparkles.base.expected.Expected!(WriteReceipt, string, Abort) sparkles.recovery.archive.appendGeneration(string directory, ulong generation, scope const(char)[] bytes, in sparkles.recovery.archive.ArchiveLayout layout = ArchiveLayout(".generation", "retired-", "SPARKLES-RECOVERY-RETIRED/1", 536870912LU)) nothrow @safeAppend bytes as generation, never replacing a file. The caller supplies an
existing private directory whose creation is already durable, and retains
earlier durable generations until this one is acknowledged durable.
appendGeneration, (alias) storage_fault_probe.readGeneration = sparkles.base.expected.Expected!(string, string, Abort) sparkles.recovery.archive.readGeneration(string directory, ulong generation, in sparkles.recovery.archive.ArchiveLayout layout = ArchiveLayout(".generation", "retired-", "SPARKLES-RECOVERY-RETIRED/1", 536870912LU)) nothrow @safeThe payload of generation, read only from a regular file.
readGeneration;
import (package) sparklessparkles.(package) sparkles.test_utilstest_utils.(module) sparkles.test_utils.tmpfstmpfs : (struct) sparkles.test_utils.tmpfs.TmpFSA scratch directory for a test, removed when the instance goes out of scope.
There are two ways to get one, and the difference is who owns the directory:
create makes a fresh, uniquely named directory and owns it:
the whole tree — files written through this instance or behind its back,
subdirectories, everything — is removed with the instance. This is what a
test wants almost every time.
share attaches to a directory that already exists and does
not own it: only the files this instance wrote are removed, and the
directory outlives it. This is for a test that deliberately has two
fixtures over one tree, or one that must not delete what another made.
Ownership is decided by which constructor ran, never by what a later call
happened to find on disk — so it cannot be forgotten, and a test that writes
into dir() through the code under test rather than through this fixture
still gets its tree cleaned up.
One instance is not thread-safe: writeFileAt appends to its file list and
the destructor reads it. That is the intended shape — one fixture per test,
used from the test's own thread — and create itself is safe to call
concurrently. Sharing a single instance across threads needs the caller's own
synchronization.
On POSIX, fixture writers are close-on-exec from the instant they open.
An unrelated child executing concurrently cannot retain a writer after its
exec and keep an executable fixture ETXTBSY after the parent's write has
completed. This applies to both writeFile and writeFileAt.
Removal is best effort and never throws. A destructor that throws during
unwinding replaces the assertion that actually failed with a cleanup error,
and on Windows that is not hypothetical — git leaves read-only objects behind
that make recursive removal fail.
TmpFS;
/// A document save as an editor makes one: create-only, or replacing with the old mode.
(alias) sparkles.base.io.errors.IoResult!(sparkles.base.vfs.types.AtomicReceipt) = sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook)The result of every I/O operation.
IoResult!(struct) sparkles.base.vfs.types.AtomicReceiptWhat a committed atomic write reports beyond the commit itself (VFO9).
Examples
static assert(AtomicMode.replace.rights == (Rights.create | Rights.write | Rights.rename));
enum keeping = AtomicMode(AtomicDisposition.replace, keepPermissions: true);
static assert(hasRights(keeping.rights, Rights.stat));
AtomicReceipt sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook) storage_fault_probe.save(string path, string bytes, bool creating) @systemA document save as an editor makes one: create-only, or replacing with the old mode.
save((alias) object.string = stringstring (parameter) string pathpath, (alias) object.string = stringstring (parameter) string bytesbytes, bool (parameter) bool creatingcreating) @system
{
enum (constant) sparkles.base.vfs.types.AtomicMode storage_fault_probe.save.create = AtomicMode(AtomicDisposition.createNew, false, true, false)create = (struct) sparkles.base.vfs.types.AtomicModeAn atomic write's mode (VFO9). Like OpenMode, a template argument of
writeFileAtomic, so the rights it needs are checked at compile time.
AtomicMode((enum) sparkles.base.vfs.types.AtomicDispositionWhat writeFileAtomic does about an entry already at the name (VFO9).
AtomicDisposition.(enum value) sparkles.base.vfs.types.AtomicDisposition.createNew = 1fail with exists, also when the entry appears during the write
createNew, syncDirectory: true);
enum (constant) sparkles.base.vfs.types.AtomicMode storage_fault_probe.save.replace = AtomicMode(AtomicDisposition.replace, true, true, false)replace = (struct) sparkles.base.vfs.types.AtomicModeAn atomic write's mode (VFO9). Like OpenMode, a template argument of
writeFileAtomic, so the rights it needs are checked at compile time.
AtomicMode((enum) sparkles.base.vfs.types.AtomicDispositionWhat writeFileAtomic does about an entry already at the name (VFO9).
AtomicDisposition.(enum value) sparkles.base.vfs.types.AtomicDisposition.replace = cast(ubyte)0ureplace it
replace, keepPermissions: true, syncDirectory: true);
auto (local variable) sparkles.base.expected.Expected!(Dir!(BlockingVfs, Rights.all), IoError, NoGcHook) dirdir = sparkles.base.expected.Expected!(Dir!(BlockingVfs, Rights.all), IoError, NoGcHook) sparkles.base.vfs.handles.openRoot!(Rights.all, sparkles.event_horizon.sys.vfs.BlockingVfs)(sparkles.event_horizon.sys.vfs.BlockingVfs* vfs, scope const(char)[] path, sparkles.base.vfs.handles.AmbientAuthority authority, sparkles.base.vfs.types.ResolvePolicy policy = ResolvePolicy(SymlinkPolicy.none, DotDotPolicy.reject, false), sparkles.base.vfs.types.CreateDefault create = CreateDefault.shared_, bool requireKernel = false) @nogc @safeOpens the directory path as a root with rights R (VFH7). The only
operation that resolves a path from the process root or current directory,
and the only one that follows symbolic links in the path it is given.
openRoot!((enum) sparkles.base.vfs.types.RightsThe operations a handle permits (VFH4). Rights are part of a handle's type, so
an operation whose right is absent does not compile (VFH6), and a derived
handle can only have fewer (VFH5).
Rights.(enum value) sparkles.base.vfs.types.Rights.all = cast(ushort)511uevery right
all)(new (struct) sparkles.event_horizon.sys.vfs.BlockingVfsThe blocking backend over POSIX system calls.
BlockingVfs, string std.path.dirName!(immutable(char))(return scope string path) pure nothrow @nogc @safeReturns the parent directory of path. On Windows, this
includes the drive letter if present. If path is a relative path and
the parent directory is the current working directory, returns ".".
Examples
assert(dirName("") == ".");
assert(dirName("file"w) == ".");
assert(dirName("dir/"d) == ".");
assert(dirName("dir///") == ".");
assert(dirName("dir/file"w.dup) == "dir");
assert(dirName("dir///file"d.dup) == "dir");
assert(dirName("dir/subdir/") == "dir");
assert(dirName("/dir/file"w) == "/dir");
assert(dirName("/file"d) == "/");
assert(dirName("/") == "/");
assert(dirName("///") == "/");
version (Windows)
{
assert(dirName(`dir\`) == `.`);
assert(dirName(`dir\\\`) == `.`);
assert(dirName(`dir\file`) == `dir`);
assert(dirName(`dir\\\file`) == `dir`);
assert(dirName(`dir\subdir\`) == `dir`);
assert(dirName(`\dir\file`) == `\dir`);
assert(dirName(`\file`) == `\`);
assert(dirName(`\`) == `\`);
assert(dirName(`\\\`) == `\`);
assert(dirName(`d:`) == `d:`);
assert(dirName(`d:file`) == `d:`);
assert(dirName(`d:\`) == `d:\`);
assert(dirName(`d:\file`) == `d:\`);
assert(dirName(`d:\dir\file`) == `d:\dir`);
assert(dirName(`\\server\share\dir\file`) == `\\server\share\dir`);
assert(dirName(`\\server\share\file`) == `\\server\share`);
assert(dirName(`\\server\share\`) == `\\server\share`);
assert(dirName(`\\server\share`) == `\\server\share`);
}
dirName((parameter) string pathpath), sparkles.base.vfs.handles.AmbientAuthority sparkles.base.vfs.handles.ambientAuthority() pure nothrow @nogc @safeThe token openRoot requires (VFH7). Only ``ambientAuthority() makes one, so
searching for that name finds every place that creates authority from a path.
ambientAuthority());
assert(!(local variable) sparkles.base.expected.Expected!(Dir!(BlockingVfs, Rights.all), IoError, NoGcHook) dirdir.bool sparkles.base.expected.Expected!(sparkles.base.vfs.handles.Dir!(BlockingVfs, Rights.all), sparkles.base.io.errors.IoError, sparkles.base.text.errors.NoGcHook).hasError!()() const pure nothrow @nogc @property @safeChecks if Expected has error
hasError);
return (parameter) bool creatingcreating ? (local variable) sparkles.base.expected.Expected!(Dir!(BlockingVfs, Rights.all), IoError, NoGcHook) dirdir.inout(sparkles.base.vfs.handles.Dir!(BlockingVfs, Rights.all)) sparkles.base.expected.Expected!(sparkles.base.vfs.handles.Dir!(BlockingVfs, Rights.all), sparkles.base.io.errors.IoError, sparkles.base.text.errors.NoGcHook).value!()() inout pure nothrow @nogc @property ref @safeReturns the expected value if there is one.
With default Abort hook, it asserts when there is no value.
It calls hook's onAccessEmptyValue otherwise.
It returns T.init when hook doesn't provide onAccessEmptyValue.
Note
Value is returned by reference only when hook provides onAccessEmptyValue.
Otherwise the T.init fallback forces it to be returned by value (a copy).
value.(constant) sparkles.base.vfs.types.AtomicMode storage_fault_probe.save.create = AtomicMode(AtomicDisposition.createNew, false, true, false)writeFileAtomic!create(sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook) sparkles.base.vfs.handles.Dir!(sparkles.event_horizon.sys.vfs.BlockingVfs, Rights.all).DirOperations!(sparkles.event_horizon.sys.vfs.BlockingVfs, Rights.all).writeFileAtomic!(AtomicMode(AtomicDisposition.createNew, false, true, false))(scope const(char)[] name, scope const(char)[] text) nothrow @nogc scope @safeditto, from text.
baseName(sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook) sparkles.base.vfs.handles.Dir!(sparkles.event_horizon.sys.vfs.BlockingVfs, Rights.all).DirOperations!(sparkles.event_horizon.sys.vfs.BlockingVfs, Rights.all).writeFileAtomic!(AtomicMode(AtomicDisposition.createNew, false, true, false))(scope const(char)[] name, scope const(char)[] text) nothrow @nogc scope @safeditto, from text.
path), (parameter) string bytesbytes)
: (local variable) sparkles.base.expected.Expected!(Dir!(BlockingVfs, Rights.all), IoError, NoGcHook) dirdir.inout(sparkles.base.vfs.handles.Dir!(BlockingVfs, Rights.all)) sparkles.base.expected.Expected!(sparkles.base.vfs.handles.Dir!(BlockingVfs, Rights.all), sparkles.base.io.errors.IoError, sparkles.base.text.errors.NoGcHook).value!()() inout pure nothrow @nogc @property ref @safeReturns the expected value if there is one.
With default Abort hook, it asserts when there is no value.
It calls hook's onAccessEmptyValue otherwise.
It returns T.init when hook doesn't provide onAccessEmptyValue.
Note
Value is returned by reference only when hook provides onAccessEmptyValue.
Otherwise the T.init fallback forces it to be returned by value (a copy).
value.(constant) sparkles.base.vfs.types.AtomicMode storage_fault_probe.save.replace = AtomicMode(AtomicDisposition.replace, true, true, false)writeFileAtomic!replace(sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook) sparkles.base.vfs.handles.Dir!(sparkles.event_horizon.sys.vfs.BlockingVfs, Rights.all).DirOperations!(sparkles.event_horizon.sys.vfs.BlockingVfs, Rights.all).writeFileAtomic!(AtomicMode(AtomicDisposition.replace, true, true, false))(scope const(char)[] name, scope const(char)[] text) nothrow @nogc scope @safeditto, from text.
baseName(sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook) sparkles.base.vfs.handles.Dir!(sparkles.event_horizon.sys.vfs.BlockingVfs, Rights.all).DirOperations!(sparkles.event_horizon.sys.vfs.BlockingVfs, Rights.all).writeFileAtomic!(AtomicMode(AtomicDisposition.replace, true, true, false))(scope const(char)[] name, scope const(char)[] text) nothrow @nogc scope @safeditto, from text.
path), (parameter) string bytesbytes);
}
private void void storage_fault_probe.recoveryFault(string mode, ref sparkles.test_utils.tmpfs.TmpFS fixture) @systemrecoveryFault((alias) object.string = stringstring (parameter) string modemode, ref (struct) sparkles.test_utils.tmpfs.TmpFSA scratch directory for a test, removed when the instance goes out of scope.
There are two ways to get one, and the difference is who owns the directory:
create makes a fresh, uniquely named directory and owns it:
the whole tree — files written through this instance or behind its back,
subdirectories, everything — is removed with the instance. This is what a
test wants almost every time.
share attaches to a directory that already exists and does
not own it: only the files this instance wrote are removed, and the
directory outlives it. This is for a test that deliberately has two
fixtures over one tree, or one that must not delete what another made.
Ownership is decided by which constructor ran, never by what a later call
happened to find on disk — so it cannot be forgotten, and a test that writes
into dir() through the code under test rather than through this fixture
still gets its tree cleaned up.
One instance is not thread-safe: writeFileAt appends to its file list and
the destructor reads it. That is the intended shape — one fixture per test,
used from the test's own thread — and create itself is safe to call
concurrently. Sharing a single instance across threads needs the caller's own
synchronization.
On POSIX, fixture writers are close-on-exec from the instant they open.
An unrelated child executing concurrently cannot retain a writer after its
exec and keep an executable fixture ETXTBSY after the parent's write has
completed. This applies to both writeFile and writeFileAt.
Removal is best effort and never throws. A destructor that throws during
unwinding replaces the assertion that actually failed with a cleanup error,
and on Windows that is not hypothetical — git leaves read-only objects behind
that make recursive removal fail.
TmpFS (parameter) sparkles.test_utils.tmpfs.TmpFS fixturefixture) @system
{
const (local variable) const(string) sourcesource = (parameter) sparkles.test_utils.tmpfs.TmpFS fixturefixture.string sparkles.test_utils.tmpfs.TmpFS.writeFile(string contents, uint suffix = 0u) @safewriteFile("original bytes");
const (local variable) const(sparkles.base.expected.Expected!(WriteReceipt, string, Abort)) firstfirst = sparkles.base.expected.Expected!(WriteReceipt, string, Abort) sparkles.recovery.archive.appendGeneration(string directory, ulong generation, scope const(char)[] bytes, in sparkles.recovery.archive.ArchiveLayout layout = ArchiveLayout(".generation", "retired-", "SPARKLES-RECOVERY-RETIRED/1", 536870912LU)) nothrow @safeAppend bytes as generation, never replacing a file. The caller supplies an
existing private directory whose creation is already durable, and retains
earlier durable generations until this one is acknowledged durable.
appendGeneration((parameter) sparkles.test_utils.tmpfs.TmpFS fixturefixture.string sparkles.test_utils.tmpfs.TmpFS.dir() const pure nothrow @nogc @safeThe scratch directory's path. It exists for as long as the instance
does (and, for share, for as long as its real owner keeps it).
dir, 1, "old unsaved");
assert((local variable) const(sparkles.base.expected.Expected!(WriteReceipt, string, Abort)) firstfirst.bool sparkles.base.expected.Expected!(sparkles.recovery.archive.WriteReceipt, string, sparkles.base.expected.Abort).hasValue!()() const pure nothrow @nogc @property @safeChecks if Expected has value
hasValue && (local variable) const(sparkles.base.expected.Expected!(WriteReceipt, string, Abort)) firstfirst.inout(sparkles.recovery.archive.WriteReceipt) sparkles.base.expected.Expected!(sparkles.recovery.archive.WriteReceipt, string, sparkles.base.expected.Abort).value!()() inout pure nothrow @nogc @property ref @safeReturns the expected value if there is one.
With default Abort hook, it asserts when there is no value.
It calls hook's onAccessEmptyValue otherwise.
It returns T.init when hook doesn't provide onAccessEmptyValue.
Note
Value is returned by reference only when hook provides onAccessEmptyValue.
Otherwise the T.init fallback forces it to be returned by value (a copy).
value.(field) bool sparkles.recovery.archive.WriteReceipt.durablethe directory sync after the commit succeeded
durable);
const (local variable) const(sparkles.base.expected.Expected!(WriteReceipt, string, Abort)) secondsecond = sparkles.base.expected.Expected!(WriteReceipt, string, Abort) sparkles.recovery.archive.appendGeneration(string directory, ulong generation, scope const(char)[] bytes, in sparkles.recovery.archive.ArchiveLayout layout = ArchiveLayout(".generation", "retired-", "SPARKLES-RECOVERY-RETIRED/1", 536870912LU)) nothrow @safeAppend bytes as generation, never replacing a file. The caller supplies an
existing private directory whose creation is already durable, and retains
earlier durable generations until this one is acknowledged durable.
appendGeneration((parameter) sparkles.test_utils.tmpfs.TmpFS fixturefixture.string sparkles.test_utils.tmpfs.TmpFS.dir() const pure nothrow @nogc @safeThe scratch directory's path. It exists for as long as the instance
does (and, for share, for as long as its real owner keeps it).
dir, 2, "new unsaved");
if ((parameter) string modemode == "recovery-directory-sync-failure")
{
assert((local variable) const(sparkles.base.expected.Expected!(WriteReceipt, string, Abort)) secondsecond.bool sparkles.base.expected.Expected!(sparkles.recovery.archive.WriteReceipt, string, sparkles.base.expected.Abort).hasValue!()() const pure nothrow @nogc @property @safeChecks if Expected has value
hasValue && !(local variable) const(sparkles.base.expected.Expected!(WriteReceipt, string, Abort)) secondsecond.inout(sparkles.recovery.archive.WriteReceipt) sparkles.base.expected.Expected!(sparkles.recovery.archive.WriteReceipt, string, sparkles.base.expected.Abort).value!()() inout pure nothrow @nogc @property ref @safeReturns the expected value if there is one.
With default Abort hook, it asserts when there is no value.
It calls hook's onAccessEmptyValue otherwise.
It returns T.init when hook doesn't provide onAccessEmptyValue.
Note
Value is returned by reference only when hook provides onAccessEmptyValue.
Otherwise the T.init fallback forces it to be returned by value (a copy).
value.(field) bool sparkles.recovery.archive.WriteReceipt.durablethe directory sync after the commit succeeded
durable && (local variable) const(sparkles.base.expected.Expected!(WriteReceipt, string, Abort)) secondsecond.inout(sparkles.recovery.archive.WriteReceipt) sparkles.base.expected.Expected!(sparkles.recovery.archive.WriteReceipt, string, sparkles.base.expected.Abort).value!()() inout pure nothrow @nogc @property ref @safeReturns the expected value if there is one.
With default Abort hook, it asserts when there is no value.
It calls hook's onAccessEmptyValue otherwise.
It returns T.init when hook doesn't provide onAccessEmptyValue.
Note
Value is returned by reference only when hook provides onAccessEmptyValue.
Otherwise the T.init fallback forces it to be returned by value (a copy).
value.(field) string sparkles.recovery.archive.WriteReceipt.warningwhat the caller should tell its user, if anything
warning.(field) ulong const(string).lengthlength);
assert(sparkles.base.expected.Expected!(string, string, Abort) sparkles.recovery.archive.readGeneration(string directory, ulong generation, in sparkles.recovery.archive.ArchiveLayout layout = ArchiveLayout(".generation", "retired-", "SPARKLES-RECOVERY-RETIRED/1", 536870912LU)) nothrow @safeThe payload of generation, read only from a regular file.
readGeneration((parameter) sparkles.test_utils.tmpfs.TmpFS fixturefixture.string sparkles.test_utils.tmpfs.TmpFS.dir() const pure nothrow @nogc @safeThe scratch directory's path. It exists for as long as the instance
does (and, for share, for as long as its real owner keeps it).
dir, 2).inout(string) sparkles.base.expected.Expected!(string, string, sparkles.base.expected.Abort).value!()() inout pure nothrow @nogc @property ref @safeReturns the expected value if there is one.
With default Abort hook, it asserts when there is no value.
It calls hook's onAccessEmptyValue otherwise.
It returns T.init when hook doesn't provide onAccessEmptyValue.
Note
Value is returned by reference only when hook provides onAccessEmptyValue.
Otherwise the T.init fallback forces it to be returned by value (a copy).
value == "new unsaved");
}
else
{
assert((parameter) string modemode == "recovery-precommit" && (local variable) const(sparkles.base.expected.Expected!(WriteReceipt, string, Abort)) secondsecond.bool sparkles.base.expected.Expected!(sparkles.recovery.archive.WriteReceipt, string, sparkles.base.expected.Abort).hasError!()() const pure nothrow @nogc @property @safeChecks if Expected has error
hasError);
assert(sparkles.base.expected.Expected!(string, string, Abort) sparkles.recovery.archive.readGeneration(string directory, ulong generation, in sparkles.recovery.archive.ArchiveLayout layout = ArchiveLayout(".generation", "retired-", "SPARKLES-RECOVERY-RETIRED/1", 536870912LU)) nothrow @safeThe payload of generation, read only from a regular file.
readGeneration((parameter) sparkles.test_utils.tmpfs.TmpFS fixturefixture.string sparkles.test_utils.tmpfs.TmpFS.dir() const pure nothrow @nogc @safeThe scratch directory's path. It exists for as long as the instance
does (and, for share, for as long as its real owner keeps it).
dir, 2).bool sparkles.base.expected.Expected!(string, string, sparkles.base.expected.Abort).hasError!()() const pure nothrow @nogc @property @safeChecks if Expected has error
hasError);
}
assert(sparkles.base.expected.Expected!(string, string, Abort) sparkles.recovery.archive.readGeneration(string directory, ulong generation, in sparkles.recovery.archive.ArchiveLayout layout = ArchiveLayout(".generation", "retired-", "SPARKLES-RECOVERY-RETIRED/1", 536870912LU)) nothrow @safeThe payload of generation, read only from a regular file.
readGeneration((parameter) sparkles.test_utils.tmpfs.TmpFS fixturefixture.string sparkles.test_utils.tmpfs.TmpFS.dir() const pure nothrow @nogc @safeThe scratch directory's path. It exists for as long as the instance
does (and, for share, for as long as its real owner keeps it).
dir, 1).inout(string) sparkles.base.expected.Expected!(string, string, sparkles.base.expected.Abort).value!()() inout pure nothrow @nogc @property ref @safeReturns the expected value if there is one.
With default Abort hook, it asserts when there is no value.
It calls hook's onAccessEmptyValue otherwise.
It returns T.init when hook doesn't provide onAccessEmptyValue.
Note
Value is returned by reference only when hook provides onAccessEmptyValue.
Otherwise the T.init fallback forces it to be returned by value (a copy).
value == "old unsaved");
assert(string std.file.readText!(string, const(string))(ref const(string) name) @safeReads and validates (using validate) a text file. S can be
an array of any character type. However, no width or endian conversions are
performed. So, if the width or endianness of the characters in the given
file differ from the width or endianness of the element type of S, then
validation will fail.
Examples
Read file with UTF-8 text.
write(deleteme, "abc"); // deleteme is the name of a temporary file
scope(exit) remove(deleteme);
string content = readText(deleteme);
assert(content == "abc");
readText((local variable) const(string) sourcesource) == "original bytes");
}
int int D main(string[] args) @systemmain((alias) object.string = stringstring[] (parameter) string[] argsargs) @system
{
assert((parameter) string[] argsargs.(field) ulong string[].lengthlength == 2, "Pass a save or recovery fault mode.");
const (local variable) const(string) modemode = (parameter) string[] argsargs[1];
auto (local variable) sparkles.test_utils.tmpfs.TmpFS fixturefixture = (struct) sparkles.test_utils.tmpfs.TmpFSA scratch directory for a test, removed when the instance goes out of scope.
There are two ways to get one, and the difference is who owns the directory:
create makes a fresh, uniquely named directory and owns it:
the whole tree — files written through this instance or behind its back,
subdirectories, everything — is removed with the instance. This is what a
test wants almost every time.
share attaches to a directory that already exists and does
not own it: only the files this instance wrote are removed, and the
directory outlives it. This is for a test that deliberately has two
fixtures over one tree, or one that must not delete what another made.
Ownership is decided by which constructor ran, never by what a later call
happened to find on disk — so it cannot be forgotten, and a test that writes
into dir() through the code under test rather than through this fixture
still gets its tree cleaned up.
One instance is not thread-safe: writeFileAt appends to its file list and
the destructor reads it. That is the intended shape — one fixture per test,
used from the test's own thread — and create itself is safe to call
concurrently. Sharing a single instance across threads needs the caller's own
synchronization.
On POSIX, fixture writers are close-on-exec from the instant they open.
An unrelated child executing concurrently cannot retain a writer after its
exec and keep an executable fixture ETXTBSY after the parent's write has
completed. This applies to both writeFile and writeFileAt.
Removal is best effort and never throws. A destructor that throws during
unwinding replaces the assertion that actually failed with a cleanup error,
and on Windows that is not hypothetical — git leaves read-only objects behind
that make recursive removal fail.
TmpFS.sparkles.test_utils.tmpfs.TmpFS sparkles.test_utils.tmpfs.TmpFS.create(string prefix = __FUNCTION__, string basePath = tempDir()) @safeCreates a fresh scratch directory and returns the fixture that owns it.
prefix names the fixture for a human reading /tmp; it does not have to
be unique. The directory actually used appends a random token and a
process-wide ordinal, which makes three problems impossible rather than
merely unlikely:
Two concurrent runs of one suite — two worktrees, two agents, a CI
matrix sharing a runner — cannot share a directory and delete each
other's fixtures mid-test.
A crashed run cannot leave a directory behind for the next run to
inherit and read a previous run's files from. The token is random
rather than the process id for exactly this case: pids are recycled,
so ``prefix-<pid>-1 recurs and would collide with the leftovers of a
run that died holding the same pid.
Two fixtures in one test function cannot collide, so neither needs
an artificial prefix to tell them apart.
The directory exists when this returns, so a test may hand dir() to the
code under test immediately; whatever that code puts there is removed
with the fixture.
prefix defaults to the calling function. That is a good name when the
call sits in the test; from a shared helper it names the helper, which is
merely less informative — no longer a correctness problem.
create();
if ((local variable) const(string) modemode.bool std.algorithm.searching.startsWith!("a == b", string, string)(string doesThisStart, string withThis) pure nothrow @nogc @safeChecks whether the given
input range starts with (one
of) the given needle(s) or, if no needles are given,
if its front element fulfils predicate pred.
For more information about pred see find.
startsWith("recovery-"))
{
void storage_fault_probe.recoveryFault(string mode, ref sparkles.test_utils.tmpfs.TmpFS fixture) @systemrecoveryFault((local variable) const(string) modemode, (local variable) sparkles.test_utils.tmpfs.TmpFS fixturefixture);
void std.stdio.writeln!(string, string)(string __param_0, string __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln((local variable) const(string) modemode, ": verified");
return 0;
}
const (local variable) const(bool) creatingcreating = (local variable) const(string) modemode == "create-failure";
const (local variable) const(string) pathpath = (local variable) const(bool) creatingcreating ? string std.path.buildPath!char(const(char)[][] paths...) pure nothrow @safeCombines one or more path segments.
This function takes a set of path segments, given as an input
range of string elements or as a set of string arguments,
and concatenates them with each other. Directory separators
are inserted between segments if necessary. If any of the
path segments are absolute (as defined by isAbsolute), the
preceding segments will be dropped.
On Windows, if one of the path segments are rooted, but not absolute
(e.g. \foo), all preceding path segments down to the previous
root will be dropped. (See below for an example.)
This function always allocates memory to hold the resulting path.
The variadic overload is guaranteed to only perform a single
allocation, as is the range version if paths is a forward
range.
Examples
version (Posix)
{
assert(buildPath("foo", "bar", "baz") == "foo/bar/baz");
assert(buildPath("/foo/", "bar/baz") == "/foo/bar/baz");
assert(buildPath("/foo", "/bar") == "/bar");
}
version (Windows)
{
assert(buildPath("foo", "bar", "baz") == `foo\bar\baz`);
assert(buildPath(`c:\foo`, `bar\baz`) == `c:\foo\bar\baz`);
assert(buildPath("foo", `d:\bar`) == `d:\bar`);
assert(buildPath("foo", `\bar`) == `\bar`);
assert(buildPath(`c:\foo`, `\bar`) == `c:\bar`);
}
buildPath((local variable) sparkles.test_utils.tmpfs.TmpFS fixturefixture.string sparkles.test_utils.tmpfs.TmpFS.dir() const pure nothrow @nogc @safeThe scratch directory's path. It exists for as long as the instance
does (and, for share, for as long as its real owner keeps it).
dir, "new.txt") : (local variable) sparkles.test_utils.tmpfs.TmpFS fixturefixture.string sparkles.test_utils.tmpfs.TmpFS.writeFile(string contents, uint suffix = 0u) @safewriteFile("original bytes");
const (local variable) const(sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook)) resultresult = sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook) storage_fault_probe.save(string path, string bytes, bool creating) @systemA document save as an editor makes one: create-only, or replacing with the old mode.
save((local variable) const(string) pathpath, "replacement bytes", (local variable) const(bool) creatingcreating);
if ((local variable) const(string) modemode == "baseline")
{
assert(!(local variable) const(sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook)) resultresult.bool sparkles.base.expected.Expected!(sparkles.base.vfs.types.AtomicReceipt, sparkles.base.io.errors.IoError, sparkles.base.text.errors.NoGcHook).hasError!()() const pure nothrow @nogc @property @safeChecks if Expected has error
hasError && (local variable) const(sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook)) resultresult.inout(sparkles.base.vfs.types.AtomicReceipt) sparkles.base.expected.Expected!(sparkles.base.vfs.types.AtomicReceipt, sparkles.base.io.errors.IoError, sparkles.base.text.errors.NoGcHook).value!()() inout pure nothrow @nogc @property ref @safeReturns the expected value if there is one.
With default Abort hook, it asserts when there is no value.
It calls hook's onAccessEmptyValue otherwise.
It returns T.init when hook doesn't provide onAccessEmptyValue.
Note
Value is returned by reference only when hook provides onAccessEmptyValue.
Otherwise the T.init fallback forces it to be returned by value (a copy).
value.(field) bool sparkles.base.vfs.types.AtomicReceipt.directorySyncedThe directory was synced after the commit, so the new name survives a
crash. False when the mode did not ask, or the sync failed.
directorySynced);
assert(string std.file.readText!(string, const(string))(ref const(string) name) @safeReads and validates (using validate) a text file. S can be
an array of any character type. However, no width or endian conversions are
performed. So, if the width or endianness of the characters in the given
file differ from the width or endianness of the element type of S, then
validation will fail.
Examples
Read file with UTF-8 text.
write(deleteme, "abc"); // deleteme is the name of a temporary file
scope(exit) remove(deleteme);
string content = readText(deleteme);
assert(content == "abc");
readText((local variable) const(string) pathpath) == "replacement bytes");
}
else if ((local variable) const(string) modemode == "directory-sync-failure")
{
assert(!(local variable) const(sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook)) resultresult.bool sparkles.base.expected.Expected!(sparkles.base.vfs.types.AtomicReceipt, sparkles.base.io.errors.IoError, sparkles.base.text.errors.NoGcHook).hasError!()() const pure nothrow @nogc @property @safeChecks if Expected has error
hasError && !(local variable) const(sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook)) resultresult.inout(sparkles.base.vfs.types.AtomicReceipt) sparkles.base.expected.Expected!(sparkles.base.vfs.types.AtomicReceipt, sparkles.base.io.errors.IoError, sparkles.base.text.errors.NoGcHook).value!()() inout pure nothrow @nogc @property ref @safeReturns the expected value if there is one.
With default Abort hook, it asserts when there is no value.
It calls hook's onAccessEmptyValue otherwise.
It returns T.init when hook doesn't provide onAccessEmptyValue.
Note
Value is returned by reference only when hook provides onAccessEmptyValue.
Otherwise the T.init fallback forces it to be returned by value (a copy).
value.(field) bool sparkles.base.vfs.types.AtomicReceipt.directorySyncedThe directory was synced after the commit, so the new name survives a
crash. False when the mode did not ask, or the sync failed.
directorySynced);
assert(string std.file.readText!(string, const(string))(ref const(string) name) @safeReads and validates (using validate) a text file. S can be
an array of any character type. However, no width or endian conversions are
performed. So, if the width or endianness of the characters in the given
file differ from the width or endianness of the element type of S, then
validation will fail.
Examples
Read file with UTF-8 text.
write(deleteme, "abc"); // deleteme is the name of a temporary file
scope(exit) remove(deleteme);
string content = readText(deleteme);
assert(content == "abc");
readText((local variable) const(string) pathpath) == "replacement bytes");
}
else
{
assert((local variable) const(string) modemode == "precommit" || (local variable) const(bool) creatingcreating);
assert((local variable) const(sparkles.base.expected.Expected!(AtomicReceipt, IoError, NoGcHook)) resultresult.bool sparkles.base.expected.Expected!(sparkles.base.vfs.types.AtomicReceipt, sparkles.base.io.errors.IoError, sparkles.base.text.errors.NoGcHook).hasError!()() const pure nothrow @nogc @property @safeChecks if Expected has error
hasError, "The syscall fault did not reach the intended save stage.");
if ((local variable) const(bool) creatingcreating) assert(!bool std.file.exists!string(string name) nothrow @nogc @safeDetermine whether the given file (or directory) exists.
exists((local variable) const(string) pathpath), "A failed atomic create wrote a destination.");
else assert(string std.file.readText!(string, const(string))(ref const(string) name) @safeReads and validates (using validate) a text file. S can be
an array of any character type. However, no width or endian conversions are
performed. So, if the width or endianness of the characters in the given
file differ from the width or endianness of the element type of S, then
validation will fail.
Examples
Read file with UTF-8 text.
write(deleteme, "abc"); // deleteme is the name of a temporary file
scope(exit) remove(deleteme);
string content = readText(deleteme);
assert(content == "abc");
readText((local variable) const(string) pathpath) == "original bytes", "A failed save changed the destination.");
}
void std.stdio.writeln!(string, string)(string __param_0, string __param_1) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln((local variable) const(string) modemode, ": verified");
return 0;
}