Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to touch a file/update its modification time on disk in Nim?

I'd like to update the modification time of some files in Nim, without actually modifying them, like Unix touch. I see there is an os.getLastModificationTime function, or more broadly os.getFileInfo, but I do not see corresponding set functions.

How do you touch a file in Nim? (If platform matters, I am currently working on Windows, sadly.)

like image 395
Keith Pinson Avatar asked Nov 17 '25 19:11

Keith Pinson


1 Answers

Unfortunately that is system specific in the current Nim version 0.18.0. On posix you'd do:

import posix
utimes("filename", nil)

In the next release you can use the platform independent os.setLastModificationTime: https://github.com/nim-lang/Nim/pull/7543

like image 119
def- Avatar answered Nov 19 '25 08:11

def-



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!