cvs commit: jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser UnixFTPEntryParser.java
scohen 2004/06/21 19:30:33 Modified:net/src/java/org/apache/commons/net/ftp/parser UnixFTPEntryParser.java Log: PR: 29689 add support for special file types, those identified in directory listings with a "type" code (first character) of s, S, m, or p. Revision ChangesPath 1.17 +8 -3 jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java Index: UnixFTPEntryParser.java === RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- UnixFTPEntryParser.java 22 Apr 2004 03:27:19 - 1.16 +++ UnixFTPEntryParser.java 22 Jun 2004 02:30:33 - 1.17 @@ -57,7 +57,7 @@ *state) */ private static final String REGEX = -"([bcdlf-])" +"([bcdlfmpSs-])" + "(((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-])))\\s+" + "(\\d+)\\s+" + "(\\S+)\\s+" @@ -115,6 +115,7 @@ String name = group(25); String endtoken = group(26); +// bcdlfmpSs- switch (typeStr.charAt(0)) { case 'd': @@ -127,8 +128,12 @@ case 'c': isDevice = true; // break; - fall through +case 'f': +case '-': + type = FTPFile.FILE_TYPE; + break; default: -type = FTPFile.FILE_TYPE; +type = FTPFile.UNKNOWN_TYPE; } file.setType(type); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser UnixFTPEntryParser.java RegexFTPFileEntryParserImpl.java
scohen 2004/04/21 20:27:19 Modified:net/src/java/org/apache/commons/net/ftp/parser UnixFTPEntryParser.java RegexFTPFileEntryParserImpl.java Log: make checkstyle happy by converting tabs to spaces. Revision ChangesPath 1.16 +220 -220 jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java Index: UnixFTPEntryParser.java === RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- UnixFTPEntryParser.java 22 Apr 2004 00:48:07 - 1.15 +++ UnixFTPEntryParser.java 22 Apr 2004 03:27:19 - 1.16 @@ -30,223 +30,223 @@ */ public class UnixFTPEntryParser extends RegexFTPFileEntryParserImpl { - /** - * months abbreviations looked for by this parser. Also used - * to determine which month is matched by the parser - */ - private static final String MONTHS = - "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"; - - /** - * this is the regular expression used by this parser. - * - * Permissions: - *r the file is readable - *w the file is writable - *x the file is executable - *- the indicated permission is not granted - *L mandatory locking occurs during access (the set-group-ID bit is - *on and the group execution bit is off) - *s the set-user-ID or set-group-ID bit is on, and the corresponding - *user or group execution bit is also on - *S undefined bit-state (the set-user-ID bit is on and the user - *execution bit is off) - *t the 1000 (octal) bit, or sticky bit, is on [see chmod(1)], and - *execution is on - *T the 1000 bit is turned on, and execution is off (undefined bit- - *state) - */ - private static final String REGEX = - "([bcdlf-])" - + "(((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-])))\\s+" - + "(\\d+)\\s+" - + "(\\S+)\\s+" - + "(?:(\\S+)\\s+)?" - + "(\\d+)\\s+" - + MONTHS + "\\s+" - + "((?:[0-9])|(?:[0-2][0-9])|(?:3[0-1]))\\s+" - + "((\\d\\d\\d\\d)|((?:[01]\\d)|(?:2[0123])|(?:[1-9])):([012345]\\d))\\s+" - + "(\\S+)(\\s*.*)"; - - - /** - * The sole constructor for a UnixFTPEntryParser object. - * - * @exception IllegalArgumentException - * Thrown if the regular expression is unparseable. Should not be seen - * under normal conditions. It it is seen, this is a sign that - * REGEX is not a valid regular expression. - */ - public UnixFTPEntryParser() - { - super(REGEX); - } - - /** - * Parses a line of a unix (standard) FTP server file listing and converts - * it into a usable format in the form of an FTPFile - * instance. If the file listing line doesn't describe a file, - * null is returned, otherwise a FTPFile - * instance representing the files in the directory is returned. - * - * @param entry A line of text from the file listing - * @return An FTPFile instance corresponding to the supplied entry - */ - public FTPFile parseFTPEntry(String entry) - { - - FTPFile file = new FTPFile(); - file.setRawListing(entry); - int type; - boolean isDevice = false; - - if (matches(entry)) - { - String typeStr = group(1); - String hardLinkCount = group(15); - String usr = group(16); - String grp = group(17); - String filesize = group(18); - String mo = group(19); - String da = group(20); - String yr = group(22); - String hr = group(23); - String min = group(24); - String name = group(25); - String endtoken = group(26); - - switch (typeStr.charAt(0)) - { - case 'd': - type = FTPFile.DIRECTORY_TYPE; - break; - case 'l': - type = FTPFile.SYMBOLIC_LINK_TYPE; - break; - case 'b': - case 'c': - isDevice = true; -
cvs commit: jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser UnixFTPEntryParser.java
scohen 2004/03/18 05:47:02 Modified:net/src/java/org/apache/commons/net/ftp/parser UnixFTPEntryParser.java Log: Fix bug 27556. It is decided that this change could not possibly cause harm and is therefore approved. CVS: -- CVS: PR: CVS: If this change addresses a PR in the problem report tracking CVS: database, then enter the PR number(s) here. CVS: Obtained from: CVS: If this change has been taken from another system, such as NCSA, CVS: then name the system in this line, otherwise delete it. CVS: Submitted by: CVS: If this code has been contributed to Apache by someone else; i.e., CVS: they sent us a patch or a new module, then include their name/email CVS: address here. If this is your work then delete this line. CVS: Reviewed by: CVS: If we are doing pre-commit code reviews and someone else has CVS: reviewed your changes, include their name(s) here. CVS: If you have not had it reviewed then delete this line. Revision ChangesPath 1.10 +2 -2 jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java Index: UnixFTPEntryParser.java === RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- UnixFTPEntryParser.java 29 Feb 2004 10:26:56 - 1.9 +++ UnixFTPEntryParser.java 18 Mar 2004 13:47:02 - 1.10 @@ -50,7 +50,7 @@ + "(\\d+)\\s+" + MONTHS + "\\s+" + "((?:[0-9])|(?:[0-2][0-9])|(?:3[0-1]))\\s+" -+ "((\\d\\d\\d\\d)|((?:[01]\\d)|(?:2[0123])):([012345]\\d))\\s" ++ "((\\d\\d\\d\\d)|((?:[01]\\d)|(?:2[0123])):([012345]\\d))\\s+" + "(\\S+)(\\s*.*)"; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]