bodewig commented on a change in pull request #86: COMPRESS-477 building a 
split zip
URL: https://github.com/apache/commons-compress/pull/86#discussion_r352363968
 
 

 ##########
 File path: 
src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
 ##########
 @@ -193,4 +193,19 @@ public String getCompressedFilename(final String 
fileName) {
         return fileName + defaultExtension;
     }
 
+    public static String getBaseName(String filename) {
+        if (filename == null) {
+            return null;
+        }
+
+        int lastSeparatorPosition = Math.max(filename.lastIndexOf('/'), 
filename.lastIndexOf('\\'));
+        String name = filename.substring(lastSeparatorPosition + 1);
 
 Review comment:
   `new File(filename).getName()` will give you the last segment of the path. 
This is more robust than the `lastIndexOf` approach.

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


With regards,
Apache Git Services

Reply via email to