-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement setModificationTime counterpart to getModificationTime #13
Comments
I have already written some code that does that. In fact I almost submitted a patch a year ago but what stopped me is the fact that there is an issue with setting modification dates: you cannot always set it independently of the last access time. In particular:
So if we want our new function to have the following signature:
we have the following options regarding the atime:
There is also a slightly different option (call it option 4): introduce the following two functions:
My vote is for 3 (with FFI for systems with |
It should be considered a feature request in unix. If they accept it then we can make use of the new feature and resort to the two-step fallback solution only if unix is doesn't support it, i.e. The downside is that users who have older versions of unix will not get the benefit of atomicity/speed on platforms that support Hence, I favor option 3 but it's not exclusive with option 4 – it could be added in the future if there's a need for it. |
When I implemented
which would have required doing multiple syscalls on platforms without
I don't see how this could be done in
Remeber, |
Here's what I'm trying to avoid: to check whether
That's a bad idea because there's no easy way for the user to find out programmatically.
It's not the most elegant what other options are there? (Though I think it makes more sense to throw an
That was my original plan, but I realize why that may not be a good idea.
It feels like the morally right approach, but it's also ugly and awkward to use (worse if
A pure boolean flag that indicates whether |
fyi, regarding non-portable API calls: haskell/unix#23 |
Ah, so directory can make use of the macros from unix via So, is there a consensus on using |
Lemme put it this way, I asked the CLC to discuss it a few days ago (but no final decision yet though as of writing): https://groups.google.com/d/topic/haskell-core-libraries/hmeSVXBcM1I/discussion |
The more I think about it, the more I think Using Regardless however, I think |
Assuming there's a statically known (Fwiw, I've been missing the equivalent of C++'s |
Aside from having a more general |
The unix package does not have a general setFileTimesHiRes that allowed setting mtime separately from atime. Therefore, we import the foreign utimensat function in the new Internal module (hsc), which also involves implementing struct timespec. Fixes haskell#13.
For POSIX it should be a no-brainer, and for Win32 it seems possible as well:
The text was updated successfully, but these errors were encountered: