ae.sys.file

File stuff

Members

Aliases

atomicCopy
alias atomicCopy = atomic!copy2

Copy a file, or replace an existing file's contents with another file's, atomically.

atomicWrite
alias atomicWrite = atomic!writeProxy

Create a file, or replace an existing file's contents atomically. Note: Consider using atomic!syncWrite or atomic!syncUpdate instead.

Functions

anyNewerThan
bool anyNewerThan(string[] sources, string target)

Returns true if the target file doesn't exist, or any of the sources are newer than the target.

atomic
auto atomic(staticMap!(Unqual, ParameterTypeTuple!impl) args)
auto atomic(staticMap!(Unqual, ParameterTypeTuple!impl) args)
atomicDg
auto atomicDg(Impl impl, Args args)

Wrap an operation which creates a file or directory, so that it is created safely and, for files, atomically (by performing the underlying operation to a temporary location, then renaming the completed file/directory to the actual target location). targetName specifies the name of the parameter containing the target file/directory.

cached
auto cached(ParameterTypeTuple!impl args)
cachedDg
auto cachedDg(Impl impl, Args args)

Wrap an operation so that it is skipped entirely if the target already exists. Implies atomic.

dirLink
void dirLink(in char[] original, in char[] link)

Link a directory. Uses symlinks on POSIX, and directory junctions on Windows.

ensureDirExists
void ensureDirExists(string path)

Make sure that the given directory exists (and create parent directories as necessary).

ensurePathExists
void ensurePathExists(string fn)

Make sure that the path to the given file name exists (and create directories as necessary).

enumerateHardLinks
string[] enumerateHardLinks(string fn)

Enumerate all hard links to the specified file.

fastFileList
string[] fastFileList(string pattern)
string[] fastFileList(string pattern0, string[] patterns...)

Shell-like expansion of ?, * and ** in path components

fileList
DirEntry[] fileList(string pattern)
DirEntry[] fileList(string pattern0, string[] patterns...)

Shell-like expansion of ?, * and ** in path components

forceDelete
void forceDelete(string fn, Flag!"recursive" recursive = No.recursive)

Forcibly remove a file or directory. If atomic is true, the entire directory is deleted "atomically" (it is first moved/renamed to another location). On Windows, this will move the file/directory out of the way, if it is in use and cannot be deleted (but can be renamed).

getFileID
ulong getFileID(string fn)

Return a file's unique ID.

getMounts
auto getMounts()

Returns an iterator of MountInfo structs.

getPathFilesystem
string getPathFilesystem(string path)

Get the name of the filesystem that the given path is mounted under. Returns null if none match.

getPathMountInfo
MountInfo getPathMountInfo(string path)

Get MountInfo with longest mount point matching path. Returns MountInfo.init if none match.

longPath
string longPath(string s)

Using UNC paths bypasses path length limitation when using Windows wide APIs.

move
void move(string src, string dst)

Try to rename; copy/delete if rename fails

newerThan
bool newerThan(string source, string target)

Returns true if the target file doesn't exist, or source is newer than the target.

openFile
File openFile(string fn, string mode = "rb")

Uses UNC paths to open a file. Requires https://github.com/D-Programming-Language/phobos/pull/1888

prependPath
string prependPath(string target, string path)

Two-argument buildPath with reversed arguments. Useful for UFCS chaining.

pushd
auto pushd(string dir)

Change the current directory to the given directory. Does nothing if dir is null. Return a scope guard which, upon destruction, restores the previous directory. Asserts that only one thread has changed the process's current directory at any time.

readAscii
ascii readAscii(string fileName)

Like std.file.readText for non-UTF8

readFile
void[] readFile(File f)

Read a File (which might be a stream) into an array

recreateEmptyDirectory
void recreateEmptyDirectory(string dir)

Create an empty directory, deleting all its contents if it already exists.

removeRecurse
void removeRecurse(string fn)

If fn is a directory, delete it recursively. Otherwise, delete the file or symlink fn.

safeReadln
string safeReadln(File f)

Avoid std.stdio.File.readln's memory corruption bug https://issues.dlang.org/show_bug.cgi?id=13856

syncUpdate
void syncUpdate(string fn, in void[] data)

Atomically save data to a file (if the file doesn't exist, or its contents differs). The update operation as a whole is not atomic, only the write is.

syncWrite
void syncWrite(string target, in void[] data)

Write data to a file, and ensure it gets written to disk before this function returns. Consider using as atomic!syncWrite. See also: syncUpdate

touch
void touch(in char[] target)

If target exists, update its modification time; otherwise create it as an empty file.

writeFileAsync
Thread writeFileAsync(File f, in void[] data)

Start a thread which writes data to f asynchronously.

Structs

MountInfo
struct MountInfo
NamedPipeImpl
struct NamedPipeImpl
XAttrs
struct XAttrs(Obj, string funPrefix)

AA-like object for accessing a file's extended attributes.

Meta

Authors

Vladimir Panteleev <vladimir@thecybershadow.net>

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.