theobisproject commented on a change in pull request #97:
URL: https://github.com/apache/commons-compress/pull/97#discussion_r429670883



##########
File path: 
src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
##########
@@ -368,10 +397,74 @@ public TarArchiveEntry(final File file) {
      * @param fileName the name to be used for the entry.
      */
     public TarArchiveEntry(final File file, final String fileName) {
+        final String normalizedName = normalizeFileName(fileName, false);
+        this.file = file.toPath();
+
+        try {
+            readFileMode(this.file, normalizedName);
+        } catch (IOException e) {
+            // Ignore for backwards compatibility

Review comment:
       > Ignoring exceptions here - and documenting that we do - seems to be 
the best approach.
   
   Added a note to the javadoc and mentioned that the exceptions can be handled 
when using the Path constructor.
   
   > Another alternative would be to not change this constructor's code to use 
the new methods at all.
   
   This would already create a feature gap between the file and the path 
constructors. The Path constructor can add the uid and gid of the file on 
linux. So this is not really preferred by me.
   
   
   
   > If we want to invoke the new methods then I'd suggest to set `modTime` and 
`size` "the old way" before invoking the new methods so we keep the old 
behaviour if things go wrong in NIO land.
   
   I implemented your suggestion with a litte change. `modTime` and `size` will 
be only added "the old way" when calling the NIO methods throws an exception. 
Hope this is ok.

##########
File path: 
src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
##########
@@ -695,6 +784,15 @@ public void setModTime(final Date time) {
         modTime = time.getTime() / MILLIS_PER_SECOND;
     }
 
+    /**
+     * Set this entry's modification time.
+     *
+     * @param time This entry's new modification time.
+     */
+    public void setModTime(final FileTime time) {

Review comment:
       Added

##########
File path: 
src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
##########
@@ -724,11 +822,26 @@ public boolean isCheckSumOK() {
      * Get this entry's file.
      *
      * <p>This method is only useful for entries created from a {@code
-     * File} but not for entries read from an archive.</p>
+     * File} or {@code Path} but not for entries read from an archive.</p>
      *
-     * @return This entry's file.
+     * @return This entry's file or null if the entry was not created from a 
file.
      */
     public File getFile() {
+        if (file == null) {
+            return null;
+        }
+        return file.toFile();
+    }
+
+    /**
+     * Get this entry's file.
+     *
+     * <p>This method is only useful for entries created from a {@code
+     * File} or {@code Path} but not for entries read from an archive.</p>
+     *
+     * @return This entry's file or null if the entry was not created from a 
file.
+     */
+    public Path getPath() {

Review comment:
       Added




----------------------------------------------------------------
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]


Reply via email to