Thread overview
[Issue 17681] [Function setTimes] additional function touch(f)
Jul 26, 2017
Vladimir Panteleev
Dec 17, 2022
Iain Buclaw
July 26, 2017
https://issues.dlang.org/show_bug.cgi?id=17681

--- Comment #1 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
The way to do this on Linux is to call utime(fileName, null).

(In reply to Martin Tschierschke from comment #0)
> The work around in the moment is to use execute("touch ~"filename").
> Not the right for a system programming language :-(

I think this is simpler:

utimes(fileName.toStringz, *cast(timeval[2]*)null);

Not sure whether this is something that comes up frequently enough to be in Phobos, especially considering it seems rather platform-specific. The name "touch" carries with it the possible implication that non-existing files will be created (as done by the program), which might not be desirable for a Phobos function.

--
July 26, 2017
https://issues.dlang.org/show_bug.cgi?id=17681

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com

--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> ---
I think a function setTimes(filename) or setTimesCurrent(filename) would be a
useful addition.

The setTimes function is cross platform and so is handy to use in platform agnostic code. It would be nice to have support for this in there somehow.

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4

--