theobisproject commented on a change in pull request #97:
URL: https://github.com/apache/commons-compress/pull/97#discussion_r419490584
##########
File path:
src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
##########
@@ -354,6 +364,24 @@ public TarArchiveEntry(final File file) {
this(file, file.getPath());
}
+ /**
+ * Construct an entry for a file. File is set to file, and the
+ * header is constructed from information from the file.
+ * The name is set from the normalized file path.
+ *
+ * <p>The entry's name will be the value of the {@code file}'s
+ * path with all file separators replaced by forward slashes and
+ * leading slashes as well as Windows drive letters stripped. The
+ * name will end in a slash if the {@code file} represents a
+ * directory.</p>
+ *
+ * @param file The file that the entry represents.
+ * @since 1.21
+ */
+ public TarArchiveEntry(final Path file) {
+ this(file, file.toString());
Review comment:
Assuming this testcases on windows the result is identical with the
existing file constructor
```java
@Test
public void testAbsoluteFileName() throws IOException {
File testFile = getFile("test1.xml").getAbsoluteFile();
// testFile absolutePath:
C:\\Users\\theobisproject\\Documents\\commons-compress\\target\\test-classes\\test1.xml
TarArchiveEntry entry = new TarArchiveEntry(testFile);
assertEquals("Users/theobisproject/Documents/commons-compress/target/test-classes/test1.xml",
entry.getName());
}
@Test
public void testAbsoluteFileNameWithPath() throws IOException {
Path testFile = getFile("test1.xml").toPath().toAbsolutePath();
// testFile absolutePath:
C:\\Users\\theobisproject\\Documents\\commons-compress\\target\\test-classes\\test1.xml
TarArchiveEntry entry = new TarArchiveEntry(testFile);
assertEquals("Users/theobisproject/Documents/commons-compress/target/test-classes/test1.xml",
entry.getName());
}
```
Should I add those as explicit testcases?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]