Code Review Request: 7168172: (fs) Files.isReadable slow on Windows
Ulf Zibis
Ulf.Zibis at CoSoCo.de
Thu Aug 23 05:59:42 PDT 2012
Am 23.08.2012 01:50, schrieb Zhong Yu:
>> public void checkAccess(Path obj, AccessMode... modes) throws
>> IOException {
>> AccessMode r = null;
>> AccessMode w = null;
>> AccessMode x = null;
>> for (AccessMode mode: modes) {
>> switch (mode) {
>> case READ : r = READ; break;
>> case WRITE : w = WRITE; break;
>> case EXECUTE : x = EXECUTE; break;
>> default: throw new AssertionError("Should not get here");
>> }
>> }
> That'll leave r==null if `modes` is empty. But an empty `modes` is
> supposed to be equivalent to [READ].
Yes, but in that case w and x are also null, so the "special-case read access" will be invoked
anyway, and the null-ness of r wouldn't matter.
>> WindowsPath file = WindowsPath.toWindowsPath(obj);
>>
>> // special-case read access to avoid needing to determine effective
>> // access to file
>> if (w == null && x == null) {
>> tryReadAccess(file);
>> return;
>> }
>>
>> ...
>> }
>>
>> -Ulf
>>
More information about the nio-dev
mailing list