ae.sys.file

File stuff

Members

Aliases

ENOATTR
alias ENOATTR = ENODATA
Undocumented in source.
FSChar
alias FSChar = WCHAR

The OS's "native" filesystem character type (private in Phobos).

FSChar
alias FSChar = char
Undocumented in source.
NamedPipe
alias NamedPipe = RefCounted!NamedPipeImpl
Undocumented in source.
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.

collectFileExistsError
alias collectFileExistsError = collectOSError!(errno => errno == core.stdc.errno.EEXIST, (code))
Undocumented in source.
collectNotFoundError
alias collectNotFoundError = collectOSError!(errno => errno == core.stdc.errno.ENOENT, (code))
Undocumented in source.
deleteHardLink
alias deleteHardLink = remove
Undocumented in source.
dirLink
alias dirLink = std.file.symlink
Undocumented in source.
getSize2
deprecated alias getSize2 = std.file.getSize
Undocumented in source.
obtainUsing
deprecated alias obtainUsing = cached
Undocumented in source.
safeUpdate
deprecated alias safeUpdate = atomic
Undocumented in source.
safeWrite
deprecated alias safeWrite = atomicWrite
Undocumented in source.
toFile
alias toFile = std.stdio.toFile
Undocumented in source.
wcscmp
alias wcscmp = core.stdc.wchar_.wcscmp
Undocumented in source.
wcslen
alias wcslen = core.stdc.wchar_.wcslen
Undocumented in source.

Functions

acquirePrivilege
void acquirePrivilege(S name)
Undocumented in source. Be warned that the author may not have intended to support it.
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)
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.

buildPath2
string buildPath2(string[] segments)
Undocumented in source. Be warned that the author may not have intended to support it.
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.

collectOSError
bool collectOSError(void delegate() operation)
Undocumented in source. Be warned that the author may not have intended to support it.
copyRecurse
void copyRecurse(DirEntry src, string dst)
Undocumented in source. Be warned that the author may not have intended to support it.
copyRecurse
void copyRecurse(string src, string dst)
Undocumented in source. Be warned that the author may not have intended to support it.
createReparsePoint
void createReparsePoint(char[] target, char[] print, char[] link)
Undocumented in source. Be warned that the author may not have intended to support it.
deleteHardLink
void deleteHardLink(string fn)

Deletes a file, which might be a read-only hard link (thus, deletes the read-only file/link without affecting other links to it).

dirLink
void dirLink(char[] original, 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
deprecated string[] fastFileList(string pattern)
deprecated string[] fastFileList(string pattern0, string[] patterns)

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

fastListDir
deprecated string[] fastListDir(string pathname, string pattern)
Undocumented in source. Be warned that the author may not have intended to support it.
fileDigest
auto fileDigest(string fn)
Undocumented in source. Be warned that the author may not have intended to support it.
fileDigestCached
auto fileDigestCached(string fn)
Undocumented in source. Be warned that the author may not have intended to support it.
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)

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).

forceDelete
deprecated void forceDelete(string fn, bool recursive)
Undocumented in source. Be warned that the author may not have intended to support it.
getFileID
ulong getFileID(string fn)

Return a file's unique ID.

getGroup
int getGroup(string fn)
Undocumented in source. Be warned that the author may not have intended to support it.
getMTime
deprecated SysTime getMTime(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
getMounts
auto getMounts()

Returns an iterator of MountInfo structs.

getOwner
int getOwner(string fn)
Undocumented in source. Be warned that the author may not have intended to support it.
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.

hardLink
void hardLink(string src, string dst)
Undocumented in source. Be warned that the author may not have intended to support it.
hardLink
void hardLink(string src, string dst)
Undocumented in source. Be warned that the author may not have intended to support it.
hardLinkCount
uint hardLinkCount(string fn)
Undocumented in source. Be warned that the author may not have intended to support it.
isHidden
bool isHidden(string fn)
Undocumented in source. Be warned that the author may not have intended to support it.
linkXAttrs
auto linkXAttrs(string path)
Undocumented in source. Be warned that the author may not have intended to support it.
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)

Polyfill for Windows fopen implementations with support for UNC paths and the 'x' subspecifier.

parseMountInfo
MountInfo parseMountInfo(char[] line)
Undocumented in source. Be warned that the author may not have intended to support it.
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

readExactly
bool readExactly(File f, ubyte[] buf)

Read exactly buf.length bytes and return true. On EOF, return false.

readFile
void[] readFile(File f)

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

readPartial
void[] readPartial(File f, void[] buf)

Like File.rawRead, but returns as soon as any data is available.

realPath
string realPath(string path)
Undocumented in source. Be warned that the author may not have intended to support it.
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

setOwner
void setOwner(string fn, int uid, int gid)
Undocumented in source. Be warned that the author may not have intended to support it.
statTimeToStdTime
SysTime statTimeToStdTime(stat_t statbuf)

Reads a time field from a stat_t with full precision (private in Phobos).

symlink
void symlink(char[] original, char[] link)
Undocumented in source. Be warned that the author may not have intended to support it.
syncUpdate
void syncUpdate(string fn, 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, 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

toFile
void toFile(void[] data, char[] name)
Undocumented in source. Be warned that the author may not have intended to support it.
touch
void touch(char[] target)

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

truncate
void truncate(File f, ulong length)
Undocumented in source. Be warned that the author may not have intended to support it.
unescapeMountString
string unescapeMountString(char[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
writeFileAsync
Thread writeFileAsync(File f, void[] data)

Start a thread which writes data to f asynchronously.

writeProxy
void writeProxy(string target, void[] data)
Undocumented in source. Be warned that the author may not have intended to support it.
writeTo
void writeTo(void[] data, char[] target)

Same as toFile, but accepts void[] and does not conflict with the std.stdio function.

xAttrs
auto xAttrs(string path)
Undocumented in source. Be warned that the author may not have intended to support it.
xAttrs
auto xAttrs(File f)
Undocumented in source. Be warned that the author may not have intended to support it.

Imports

No (from std.typecons)
public import std.typecons : No, Yes;
Undocumented in source.
Yes (from std.typecons)
public import std.typecons : No, Yes;
Undocumented in source.

Manifest constants

targetParameterNames
enum targetParameterNames;
Undocumented in source.

Structs

MountInfo
struct MountInfo
Undocumented in source.
NamedPipeImpl
struct NamedPipeImpl
Undocumented in source.
XAttrs
struct XAttrs(Obj, string funPrefix)

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

Templates

listDir
template listDir(alias handler)

Fast templated directory iterator

mdFile
template mdFile()
Undocumented in source.
mdFileCached
template mdFileCached()
Undocumented in source.
withTarget
template withTarget(alias targetGen, alias fun)
Undocumented in source.

Meta

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/.

Authors

Vladimir Panteleev <vladimir@thecybershadow.net>