82 } |
83 } |
83 if (!useLutimes) { |
84 if (!useLutimes) { |
84 fd = file.openForAttributeAccess(followLinks); |
85 fd = file.openForAttributeAccess(followLinks); |
85 if (fd != -1) { |
86 if (fd != -1) { |
86 haveFd = true; |
87 haveFd = true; |
87 useFutimes = futimesSupported(); |
88 if (!(useFutimens = futimensSupported())) { |
|
89 useFutimes = futimesSupported(); |
|
90 } |
88 } |
91 } |
89 } |
92 } |
90 } catch (UnixException x) { |
93 } catch (UnixException x) { |
91 if (!(x.errno() == UnixConstants.ENXIO || |
94 if (!(x.errno() == UnixConstants.ENXIO || |
92 (x.errno() == UnixConstants.ELOOP && useLutimes))) { |
95 (x.errno() == UnixConstants.ELOOP && useLutimes))) { |
110 } catch (UnixException x) { |
113 } catch (UnixException x) { |
111 x.rethrowAsIOException(file); |
114 x.rethrowAsIOException(file); |
112 } |
115 } |
113 } |
116 } |
114 |
117 |
115 // uptime times |
118 // update times |
116 long modValue = lastModifiedTime.to(TimeUnit.MICROSECONDS); |
119 TimeUnit timeUnit = useFutimens ? |
117 long accessValue= lastAccessTime.to(TimeUnit.MICROSECONDS); |
120 TimeUnit.NANOSECONDS : TimeUnit.MICROSECONDS; |
|
121 long modValue = lastModifiedTime.to(timeUnit); |
|
122 long accessValue= lastAccessTime.to(timeUnit); |
118 |
123 |
119 boolean retry = false; |
124 boolean retry = false; |
120 try { |
125 try { |
121 if (useFutimes) { |
126 if (useFutimens) { |
|
127 futimens(fd, accessValue, modValue); |
|
128 } else if (useFutimes) { |
122 futimes(fd, accessValue, modValue); |
129 futimes(fd, accessValue, modValue); |
123 } else if (useLutimes) { |
130 } else if (useLutimes) { |
124 lutimes(file, accessValue, modValue); |
131 lutimes(file, accessValue, modValue); |
125 } else { |
132 } else { |
126 utimes(file, accessValue, modValue); |
133 utimes(file, accessValue, modValue); |
137 } |
144 } |
138 if (retry) { |
145 if (retry) { |
139 if (modValue < 0L) modValue = 0L; |
146 if (modValue < 0L) modValue = 0L; |
140 if (accessValue < 0L) accessValue= 0L; |
147 if (accessValue < 0L) accessValue= 0L; |
141 try { |
148 try { |
142 if (useFutimes) { |
149 if (useFutimens) { |
|
150 futimens(fd, accessValue, modValue); |
|
151 } else if (useFutimes) { |
143 futimes(fd, accessValue, modValue); |
152 futimes(fd, accessValue, modValue); |
144 } else if (useLutimes) { |
153 } else if (useLutimes) { |
145 lutimes(file, accessValue, modValue); |
154 lutimes(file, accessValue, modValue); |
146 } else { |
155 } else { |
147 utimes(file, accessValue, modValue); |
156 utimes(file, accessValue, modValue); |