[
https://issues.apache.org/jira/browse/IO-890?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18074516#comment-18074516
]
Gary D. Gregory commented on IO-890:
------------------------------------
Hello [~sparkhi]
The method is behaving exactly as described in the Javadoc:
{code:java}
/**
* Gets the name minus the path from a full file name.
* <p>
* This method will handle a file in either Unix or Windows format.
* The text after the last forward or backslash is returned.
* </p>
* <pre>
* a/b/c.txt --> c.txt
* a\b\c.txt --> c.txt
* a.txt --> a.txt
* a/b/c --> c
* a/b/c/ --> ""
* </pre>
* <p>
* The output will be the same irrespective of the machine that the code is
running on.
* </p>
*
* @param fileName the file name, null returns null.
* @return the name of the file without the path, or an empty string if
none exists.
* @throws IllegalArgumentException if the file name contains the null
character ({@code U+0000}).
*/
{code}
A concern would be if the behavior (and Javadoc) was changed to be OS-based,
then that could break existing applications. I am not sure how likely this
would be.
> getName method in FilenameUtils does not return full name if the filename
> contains a separator character
> --------------------------------------------------------------------------------------------------------
>
> Key: IO-890
> URL: https://issues.apache.org/jira/browse/IO-890
> Project: Commons IO
> Issue Type: Bug
> Reporter: Saurabh Parkhi
> Priority: Minor
>
> Tried and Replicated on Linux
> * Create a file with backslash in the name e.g. `touch
> file'\'withbackslash.txt`
> * try to get the filename from the full path, it splits on the last
> separator returning only part of the file name
>
> As the method operates only on String, it fails, if it generates a File or
> Path object and get the filename, it will work
--
This message was sent by Atlassian Jira
(v8.20.10#820010)