Thread overview
[Issue 10240] It should be possible to check exists and isDir/isFile with a single stat call
Oct 03, 2017
RazvanN
Oct 05, 2017
RazvanN
Oct 05, 2017
ZombineDev
Oct 05, 2017
ZombineDev
Oct 05, 2017
ZombineDev
Dec 17, 2022
Iain Buclaw
October 03, 2017
https://issues.dlang.org/show_bug.cgi?id=10240

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com
           Assignee|nobody@puremagic.com        |razvan.nitu1305@gmail.com

--
October 05, 2017
https://issues.dlang.org/show_bug.cgi?id=10240

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
There are 2 ways to solve this:

1. Either check that the file or directory exists inside the isDir/isFile functions and return false if the path does not exist or the input string doesn't designate a directory/file. This is troublesome since you have one value for 2 different semantics.

2. Create a function existsAndIsDir/File where you can call stat a single time. This means adding 2 new functions that add no extra functionality for the benefit of a micro-optimization.

In my opinion we should close this as WONTFIX.

--
October 05, 2017
https://issues.dlang.org/show_bug.cgi?id=10240

ZombineDev <petar.p.kirov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |petar.p.kirov@gmail.com

--- Comment #2 from ZombineDev <petar.p.kirov@gmail.com> ---
I believe the right solution add a function akin to C++17's file_status (http://en.cppreference.com/w/cpp/experimental/fs/file_status) which would return a struct essentially being union of

https://msdn.microsoft.com/en-us/library/windows/desktop/aa364946(v=vs.85).aspx
on Windows

and

http://pubs.opengroup.org/onlinepubs/009695399/functions/stat.html on Posix.

That way users would be to obtain more information in a single call.

Unfortunately we have all kinds of functions defined in https://dlang.org/phobos-prerelease/std_file General, Attributes, Timestamp

while a single function returning a struct would be much more useful.

--
October 05, 2017
https://issues.dlang.org/show_bug.cgi?id=10240

--- Comment #3 from ZombineDev <petar.p.kirov@gmail.com> ---
> while a single function returning a struct would be much more useful...

... and more type-safe.

--
October 05, 2017
https://issues.dlang.org/show_bug.cgi?id=10240

--- Comment #4 from ZombineDev <petar.p.kirov@gmail.com> ---
> I believe the right solution add a function akin to C++17's file_status (http://en.cppreference.com/w/cpp/experimental/fs/file_status)

Here I meant this function: http://en.cppreference.com/w/cpp/experimental/fs/status

as file_status is a struct.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=10240

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4

--