Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Sarankumar Baskar, Matt Pryor, Gary Gregory" issue="NET-745">[Javadoc] Improve UnixFTPEntryParser when filename with leading space when listing contains a year instead of time (IBM i example) (#405).</action>
<action type="fix" dev="ggregory" due-to="Javid Khan, Gary Gregory">Force Gregorian calendar in FTP listing timestamp parsers (##406).</action>
<action type="fix" dev="ggregory" due-to="Arpit Jain, Gary Gregory">TFTPRequestPacket now throws TFTPPacketException instead of ArrayIndexOutOfBoundsException (#407).</action>
<action type="fix" dev="ggregory" due-to="Inf1mum" issue="NET-200">UnixFTPEntryParser now treats block and character devices as FTPFile.UNKNOWN_TYPE instead of FTPFile.FILE_TYPE.</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Add and use FTPFile.setUserPermission(int, boolean).</action>
<!-- UPDATE -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ public FTPFile parseFTPEntry(final String entry) {
case 'b':
case 'c':
isDevice = true;
type = FTPFile.FILE_TYPE; // TODO change this if DEVICE_TYPE implemented
// NET-200: block and character devices are not regular files.
type = FTPFile.UNKNOWN_TYPE;
break;
case 'f':
case '-':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ protected void doAdditionalGoodTests(final String test, final FTPFile f) {
case 'b':
case 'c':
assertEquals(0, f.getHardLinkCount());
// falls through$ TODO this needs to be fixed if a device type is introduced
// NET-200: block and character devices are not regular files.
assertEquals(FTPFile.UNKNOWN_TYPE, type, "Type of " + test);
break;
case 'f':
case '-':
assertEquals(FTPFile.FILE_TYPE, type, "Type of " + test);
Expand Down Expand Up @@ -228,6 +230,26 @@ void testNET294() {
assertEquals("bloplab 7 cd1.img", f.getName());
}

// https://issues.apache.org/jira/browse/NET-200
@Test
void testNET200BlockAndCharacterDevicesAreNotFiles() {
final String[] deviceEntries = {
// block device
"brw-rw---- 1 root disk 8, 0 Jan 22 2001 sda",
// character device
"crw-rw-rw- 1 root root 1, 3 Jan 22 2001 null"};
for (final String entry : deviceEntries) {
final FTPFile f = getParser().parseFTPEntry(entry);
assertNotNull(f, "Failed to parse " + entry);
assertEquals(FTPFile.UNKNOWN_TYPE, f.getType(), "Type of " + entry);
assertFalse(f.isFile(), "Device must not be a regular file: " + entry);
assertFalse(f.isDirectory(), "Device must not be a directory: " + entry);
assertTrue(f.isUnknown(), "Device must be of unknown type: " + entry);
assertEquals(0, f.getHardLinkCount(), "Hard link count of " + entry);
assertNotNull(f.getTimestamp(), "Expected to find a timestamp for " + entry);
}
}

@Test
void testNoSpacesBeforeFileSize() {
final FTPFile f = getParser().parseFTPEntry("drwxr-x---+1464 chrism chrism 41472 Feb 25 13:17 20090225");
Expand Down