mirror of
https://github.com/dlang/phobos.git
synced 2025-05-12 07:08:48 +03:00
Merge pull request #495 from blackwhale/issue-7138
dirEntries issues 7264 & 7138
This commit is contained in:
commit
58f1b2bc51
1 changed files with 29 additions and 28 deletions
57
std/file.d
57
std/file.d
|
@ -2102,20 +2102,21 @@ else version(Windows)
|
|||
struct DirEntry
|
||||
{
|
||||
public:
|
||||
alias name this;
|
||||
|
||||
@property string name() const
|
||||
@property string name() const pure nothrow
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
@property bool isDir() const
|
||||
@property bool isDir() const pure nothrow
|
||||
{
|
||||
return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
|
||||
deprecated alias isDir isdir;
|
||||
|
||||
@property bool isFile() const
|
||||
@property bool isFile() const pure nothrow
|
||||
{
|
||||
//Are there no options in Windows other than directory and file?
|
||||
//If there are, then this probably isn't the best way to determine
|
||||
|
@ -2125,12 +2126,12 @@ else version(Windows)
|
|||
|
||||
deprecated alias isFile isfile;
|
||||
|
||||
@property bool isSymlink() const
|
||||
@property bool isSymlink() const pure nothrow
|
||||
{
|
||||
return (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
|
||||
}
|
||||
|
||||
@property ulong size() const
|
||||
@property ulong size() const pure nothrow
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
@ -2140,7 +2141,7 @@ else version(Windows)
|
|||
return sysTimeToDTime(_timeCreated);
|
||||
}
|
||||
|
||||
@property SysTime timeCreated() const
|
||||
@property SysTime timeCreated() const pure nothrow
|
||||
{
|
||||
return cast(SysTime)_timeCreated;
|
||||
}
|
||||
|
@ -2150,7 +2151,7 @@ else version(Windows)
|
|||
return sysTimeToDTime(_timeLastAccessed);
|
||||
}
|
||||
|
||||
@property SysTime timeLastAccessed() const
|
||||
@property SysTime timeLastAccessed() const pure nothrow
|
||||
{
|
||||
return cast(SysTime)_timeLastAccessed;
|
||||
}
|
||||
|
@ -2160,17 +2161,17 @@ else version(Windows)
|
|||
return sysTimeToDTime(_timeLastModified);
|
||||
}
|
||||
|
||||
@property SysTime timeLastModified() const
|
||||
@property SysTime timeLastModified() const pure nothrow
|
||||
{
|
||||
return cast(SysTime)_timeLastModified;
|
||||
}
|
||||
|
||||
@property uint attributes() const
|
||||
@property uint attributes() const pure nothrow
|
||||
{
|
||||
return _attributes;
|
||||
}
|
||||
|
||||
@property uint linkAttributes() const
|
||||
@property uint linkAttributes() const pure nothrow
|
||||
{
|
||||
return _attributes;
|
||||
}
|
||||
|
@ -2246,8 +2247,9 @@ else version(Posix)
|
|||
struct DirEntry
|
||||
{
|
||||
public:
|
||||
alias name this;
|
||||
|
||||
@property string name() const
|
||||
@property string name() const pure nothrow
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
@ -3082,23 +3084,7 @@ public:
|
|||
@property bool empty(){ return impl.empty; }
|
||||
@property DirEntry front(){ return impl.front; }
|
||||
void popFront(){ impl.popFront(); }
|
||||
int opApply(int delegate(ref string name) dg)
|
||||
{
|
||||
foreach(DirEntry v; impl.refCountedPayload)
|
||||
{
|
||||
string s = v.name;
|
||||
if(dg(s))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int opApply(int delegate(ref DirEntry name) dg)
|
||||
{
|
||||
foreach(DirEntry v; impl.refCountedPayload)
|
||||
if(dg(v))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
/++
|
||||
Returns an input range of DirEntry that lazily iterates a given directory,
|
||||
|
@ -3189,6 +3175,21 @@ unittest
|
|||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
//issue 7264
|
||||
foreach (string name; dirEntries(".", "*.d", SpanMode.breadth))
|
||||
{
|
||||
|
||||
}
|
||||
foreach (entry; dirEntries(".", SpanMode.breadth))
|
||||
{
|
||||
static assert(is(typeof(entry) == DirEntry));
|
||||
}
|
||||
//issue 7138
|
||||
auto a = array(dirEntries(".", SpanMode.shallow));
|
||||
}
|
||||
|
||||
/++
|
||||
Convenience wrapper for filtering file names with a glob pattern.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue