Closed p5pRT closed 20 years ago
On Solaris\, and presumably most systems\, the utime(2) system call applies more lenient authorization checks if I only want to set the time to now (by passing a NULL struct utimbuf). But the perl utime function always uses the form that requires me to own the file. I suggest that if the first two arguments to utime are both undef\, perl call the NULL form of utime(2).
Andrew
I've implemented this\, cause it sounds like a good idea. (There are lots of other places where Perl defers to the underlying C library. This is a good place to do it.) This should not break any existing functionality.
Patch below.
The documentation for 'utime(2)' on all the systems I could get my hands on says that this is valid. One\, even says this in a section labeled "STANDARDS".
-R
Thanks! Can I suggest:
+If the fisrt two two elements of the list are C\
\, then the +system (C Library) utime will be called with a null second argument. +On most machines\, this will set the files access and modification time +to the current time. (i.e. equivalent to the example above.)
Replace "On most ..." with something like
This will set the file's access and modification time to the current time (i.e. equivalent to the example above)\, but (on most systems) will work on any file you can write to\, not just files you own.
I think if some system were found to do something else with a null argument\, this should be worked around in perl.
(Even if you don't take my suggestion\, take my apostrophe\, O illustrious porter. Also\, s/fisrt/first/\, s/two two/two/.)
Andrew
Thanks! Can I suggest:
+If the fisrt two two elements of the list are C\
\, then the +system (C Library) utime will be called with a null second argument. +On most machines\, this will set the files access and modification time +to the current time. (i.e. equivalent to the example above.) Replace "On most ..." with something like
This will set the file's access and modification time to the current time (i.e. equivalent to the example above)\, but (on most systems) will work on any file you can write to\, not just files you own.
The ownership rules vary from system to system\, but are generaly the same for both cases. (i.e providing arguments/not providing arguments) Because that is dependent on the actual underlying implementation\, I don't think the perl documentation should mention that.
I think if some system were found to do something else with a null argument\, this should be worked around in perl.
(Even if you don't take my suggestion\, take my apostrophe\, O illustrious porter. Also\, s/fisrt/first/\, s/two two/two/.)
Andrew
New doc patch follows:
-R
I thought about that\, and it was starting to look real ugly. the t/io/fs.t tests for utime are a small nest of platform varying tests\, and I really didn't want to touch or expand them.
The patch shouldn't change the common case functionality.
-R
I believe "rat's nest" is the technical term :-)
and I really didn't want to touch or expand them.
The patch shouldn't change the common case functionality.
True. I'm just afraid that in some far-away platform utime(2) will crash and burn with NULL arguments...
-R
Migrated from rt.perl.org#1614 (status was 'resolved')
Searchable as RT1614$