PostelnicuGeorge commented on a change in pull request #236:
URL: https://github.com/apache/commons-compress/pull/236#discussion_r775142589



##########
File path: src/main/java/org/apache/commons/compress/utils/FileNameUtils.java
##########
@@ -50,6 +51,29 @@ public static String getExtension(final String filename) {
         return name.substring(extensionPosition + 1);
     }
 
+    /**
+     * Returns the extension (i.e. the part after the last ".") of a file.
+     * <p>Will return an empty string if the file name doesn't contain
+     * any dots. Only the last segment of a the file name is consulted
+     * - i.e. all leading directories of the {@code filename}
+     * parameter are skipped.</p>
+     * @return the extension of filename
+     * @param path the path of the file to obtain the extension of.
+     * @since 1.22
+     */
+    public static String getExtensionFrom(final Path path) {
+        if (path == null) {
+            return null;
+        }
+
+        final String name = path.getFileName().toString();
+        final int extensionPosition = name.lastIndexOf('.');
+        if (extensionPosition < 0) {

Review comment:
       The package private can't be because of the usages and due to the fact 
that I would like that these 2 methods will replace the original ones in the 
tests and in the main code usages. Also I didn't try to change the 
functionality that was there before only to make it work for nio, that's why I 
didn't attempt any enhancements anywhere only equivalent methods from io to nio.




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

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to