diff --git a/std/file.d b/std/file.d index a110bdb5103..129f6ca8ff1 100644 --- a/std/file.d +++ b/std/file.d @@ -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; @@ -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; /++ @@ -3688,7 +3688,7 @@ auto de2 = DirEntry("/usr/share/include"); assert(de2.isDir); -------------------- +/ - @property bool isDir(); + @property bool isDir() scope; /++ @@ -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 @@ -3723,13 +3723,13 @@ 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.) @@ -3737,7 +3737,7 @@ assert(!de2.isFile); 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 @@ -3748,13 +3748,13 @@ 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.) @@ -3762,7 +3762,7 @@ assert(!de2.isFile); 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`. @@ -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 @@ -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*; @@ -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) @@ -3848,17 +3848,17 @@ 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 @@ -3866,37 +3866,37 @@ else version (Windows) 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; } @@ -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(); @@ -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; @@ -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; @@ -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; @@ -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"]); @@ -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; } @@ -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; } @@ -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)); diff --git a/std/path.d b/std/path.d index d78438419f0..78679bb400f 100644 --- a/std/path.d +++ b/std/path.d @@ -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; @@ -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;