Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions std/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ else

version (StdUnittest) private struct TestAliasedString
{
string get() @safe @nogc pure nothrow { return _s; }
string get() @safe @nogc pure nothrow return scope { return _s; }
alias get this;
@disable this(this);
string _s;
Expand Down Expand Up @@ -3672,7 +3672,7 @@ auto de2 = DirEntry("/usr/share/include");
assert(de2.name == "/usr/share/include");
--------------------
+/
@property string name() const;
@property string name() const return scope;


/++
Expand All @@ -3688,7 +3688,7 @@ auto de2 = DirEntry("/usr/share/include");
assert(de2.isDir);
--------------------
+/
@property bool isDir();
@property bool isDir() scope;


/++
Expand All @@ -3714,7 +3714,7 @@ auto de2 = DirEntry("/usr/share/include");
assert(!de2.isFile);
--------------------
+/
@property bool isFile();
@property bool isFile() scope;

/++
Returns whether the file represented by this `DirEntry` is a
Expand All @@ -3723,21 +3723,21 @@ assert(!de2.isFile);
On Windows, return `true` when the file is either a symbolic
link or a junction point.
+/
@property bool isSymlink();
@property bool isSymlink() scope;

/++
Returns the size of the the file represented by this `DirEntry`
in bytes.
+/
@property ulong size();
@property ulong size() scope;

/++
$(BLUE This function is Windows-Only.)

Returns the creation time of the file represented by this
`DirEntry`.
+/
@property SysTime timeCreated() const;
@property SysTime timeCreated() const scope;

/++
Returns the time that the file represented by this `DirEntry` was
Expand All @@ -3748,21 +3748,21 @@ assert(!de2.isFile);
`timeLastAccessed` will return the same value as
`timeLastModified`.
+/
@property SysTime timeLastAccessed();
@property SysTime timeLastAccessed() scope;

/++
Returns the time that the file represented by this `DirEntry` was
last modified.
+/
@property SysTime timeLastModified();
@property SysTime timeLastModified() scope;

/++
$(BLUE This function is POSIX-Only.)

Returns the time that the file represented by this `DirEntry` was
last changed (not only in contents, but also in permissions or ownership).
+/
@property SysTime timeStatusChanged() const;
@property SysTime timeStatusChanged() const scope;

/++
Returns the _attributes of the file represented by this `DirEntry`.
Expand All @@ -3778,7 +3778,7 @@ assert(!de2.isFile);
symbolic link, then _attributes are the _attributes of the file
pointed to by the symbolic link.
+/
@property uint attributes();
@property uint attributes() scope;

/++
On POSIX systems, if the file represented by this `DirEntry` is a
Expand All @@ -3790,7 +3790,7 @@ assert(!de2.isFile);
exists on Windows so that you don't have to special-case code for
Windows when dealing with symbolic links.
+/
@property uint linkAttributes();
@property uint linkAttributes() scope;

version (Windows)
alias stat_t = void*;
Expand All @@ -3800,7 +3800,7 @@ assert(!de2.isFile);

The `stat` struct gotten from calling `stat`.
+/
@property stat_t statBuf();
@property stat_t statBuf() scope;
}
}
else version (Windows)
Expand Down Expand Up @@ -3848,55 +3848,55 @@ else version (Windows)
_attributes = fd.dwFileAttributes;
}

@property string name() const pure nothrow
@property string name() const pure nothrow return scope
{
return _name;
}

@property bool isDir() const pure nothrow
@property bool isDir() const pure nothrow scope
{
return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
}

@property bool isFile() const pure nothrow
@property bool isFile() const pure nothrow scope
{
//Are there no options in Windows other than directory and file?
//If there are, then this probably isn't the best way to determine
//whether this DirEntry is a file or not.
return !isDir;
}

@property bool isSymlink() const pure nothrow
@property bool isSymlink() const pure nothrow scope
{
return (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
}

@property ulong size() const pure nothrow
@property ulong size() const pure nothrow scope
{
return _size;
}

@property SysTime timeCreated() const pure nothrow
@property SysTime timeCreated() const pure nothrow scope
{
return cast(SysTime)_timeCreated;
}

@property SysTime timeLastAccessed() const pure nothrow
@property SysTime timeLastAccessed() const pure nothrow scope
{
return cast(SysTime)_timeLastAccessed;
}

@property SysTime timeLastModified() const pure nothrow
@property SysTime timeLastModified() const pure nothrow scope
{
return cast(SysTime)_timeLastModified;
}

@property uint attributes() const pure nothrow
@property uint attributes() const pure nothrow scope
{
return _attributes;
}

@property uint linkAttributes() const pure nothrow
@property uint linkAttributes() const pure nothrow scope
{
return _attributes;
}
Expand Down Expand Up @@ -3971,74 +3971,74 @@ else version (Posix)
}
}

@property string name() const pure nothrow
@property string name() const pure nothrow return scope
{
return _name;
}

@property bool isDir()
@property bool isDir() scope
{
_ensureStatOrLStatDone();

return (_statBuf.st_mode & S_IFMT) == S_IFDIR;
}

@property bool isFile()
@property bool isFile() scope
{
_ensureStatOrLStatDone();

return (_statBuf.st_mode & S_IFMT) == S_IFREG;
}

@property bool isSymlink()
@property bool isSymlink() scope
{
_ensureLStatDone();

return (_lstatMode & S_IFMT) == S_IFLNK;
}

@property ulong size()
@property ulong size() scope
{
_ensureStatDone();
return _statBuf.st_size;
}

@property SysTime timeStatusChanged()
@property SysTime timeStatusChanged() scope
{
_ensureStatDone();

return statTimeToStdTime!'c'(_statBuf);
}

@property SysTime timeLastAccessed()
@property SysTime timeLastAccessed() scope
{
_ensureStatDone();

return statTimeToStdTime!'a'(_statBuf);
}

@property SysTime timeLastModified()
@property SysTime timeLastModified() scope
{
_ensureStatDone();

return statTimeToStdTime!'m'(_statBuf);
}

@property uint attributes()
@property uint attributes() scope
{
_ensureStatDone();

return _statBuf.st_mode;
}

@property uint linkAttributes()
@property uint linkAttributes() scope
{
_ensureLStatDone();

return _lstatMode;
}

@property stat_t statBuf()
@property stat_t statBuf() scope
{
_ensureStatDone();

Expand All @@ -4050,7 +4050,7 @@ else version (Posix)
This is to support lazy evaluation, because doing stat's is
expensive and not always needed.
+/
void _ensureStatDone() @trusted
void _ensureStatDone() @trusted scope
{
import std.exception : enforce;

Expand All @@ -4070,7 +4070,7 @@ else version (Posix)
Try both stat and lstat for isFile and isDir
to detect broken symlinks.
+/
void _ensureStatOrLStatDone() @trusted
void _ensureStatOrLStatDone() @trusted scope
{
if (_didStat)
return;
Expand All @@ -4092,7 +4092,7 @@ else version (Posix)
This is to support lazy evaluation, because doing stat's is
expensive and not always needed.
+/
void _ensureLStatDone() @trusted
void _ensureLStatDone() @trusted scope
{
import std.exception : enforce;

Expand Down Expand Up @@ -4616,7 +4616,7 @@ enum SpanMode
root.buildPath("animals", "dog").mkdir;
root.buildPath("plants").mkdir;

alias removeRoot = (e) => e.relativePath(root);
alias removeRoot = (return scope e) => e.relativePath(root);

root.dirEntries(SpanMode.shallow).map!removeRoot.equal(
["plants", "animals"]);
Expand Down Expand Up @@ -4981,7 +4981,7 @@ auto dirEntries(string path, SpanMode mode, bool followSymlink = true)

return std.file.dirEntries(pathname, SpanMode.shallow)
.filter!(a => a.isFile)
.map!(a => std.path.baseName(a.name))
.map!((return a) => std.path.baseName(a.name))
.array;
}

Expand Down Expand Up @@ -5024,7 +5024,7 @@ auto dirEntries(string path, SpanMode mode, bool followSymlink = true)
auto len = enforce(walkLength(dirEntries(absolutePath(relpath), mode)));
assert(walkLength(dirEntries(relpath, mode)) == len);
assert(equal(
map!(a => absolutePath(a.name))(dirEntries(relpath, mode)),
map!((return a) => absolutePath(a.name))(dirEntries(relpath, mode)),
map!(a => a.name)(dirEntries(absolutePath(relpath), mode))));
return len;
}
Expand Down Expand Up @@ -5174,7 +5174,7 @@ auto dirEntries(string path, string pattern, SpanMode mode,
foreach (file; files)
write(file, "nothing");

auto result = dirEntries(dir, SpanMode.shallow).map!(a => a.name.normalize()).array();
auto result = dirEntries(dir, SpanMode.shallow).map!((return a) => a.name.normalize()).array();
sort(result);

assert(equal(files, result));
Expand Down
4 changes: 2 additions & 2 deletions std/path.d
Original file line number Diff line number Diff line change
Expand Up @@ -2747,7 +2747,7 @@ else version (Posix)
See_Also:
$(LREF asAbsolutePath) which does not allocate
*/
string absolutePath(string path, lazy string base = getcwd())
string absolutePath(return scope string path, lazy string base = getcwd())
@safe pure
{
import std.array : array;
Expand Down Expand Up @@ -2893,7 +2893,7 @@ if (isConvertibleToString!R)
`Exception` if the specified _base directory is not absolute.
*/
string relativePath(CaseSensitive cs = CaseSensitive.osDefault)
(string path, lazy string base = getcwd())
(scope return string path, lazy string base = getcwd())
{
if (!isAbsolute(path))
return path;
Expand Down