I am currently in the process of setting up a test server for the vfs project,
and guess what.
I have found a but in the NET library.
The Regex-String contains the following line
"(((r|)(w|)(x|))((r|)(w|)(x|))((r|)(w|)(x|-)))
s+"
But this will fail (maybe depends on the used ftpd server?) if the file has
other permissions set (e.g. setuid bit, sticky, ....)
Using listFiles will return a null value for every entry where this regexp wont
match.
I could send a patch if one tells me what you would like to see as patch.
1) extend FTPFile to handle these special modes.
2) ignore any other mode than "rwx". At least the regexp has to be expanded.
3) same as 2 except "s" is mapped to "x".
s: set user or group ID on execution
The possible values for the permissions are: rwxSst (for what i have seen for
now, maybe there are some other)
for (int access = 0; access < 3; access++, g += 4)
{ // Use != '-' to avoid having to check for suid and sticky bits file.setPermission(access, FTPFile.READ_PERMISSION, (!group(g).equals("-"))); file.setPermission(access, FTPFile.WRITE_PERMISSION, (!group(g + 1).equals("-"))); file.setPermission(access, FTPFile.EXECUTE_PERMISSION, (!group(g + 2).equals("-"))); }As you can see by the above code snippet from UnixFTPEntryParser the ignoring of suid and
sticky bits is by design. However, you are correct that the regex must handle these or the
entry will fail to parse. While this will not cause a NullPointerException, the parsing engine will
remove the unparsed entry from the listing and that's not good. Fixing the regex will prevent
this from happening. And since the current code checks for inequality to "-" no special
mappings are needed.
So I would say the patch should be the following:
1) fix the regex as you have indicated
2) add lines to the JUnit test for this class testing the new functionality.