[ 
https://issues.apache.org/jira/browse/IO-783?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17914136#comment-17914136
 ] 

Gary D. Gregory commented on IO-783:
------------------------------------

-1 for [GitHub Pull Request #629|https://github.com/apache/commons-io/pull/629]
- The current PR is completely wrong on Windows:
  - The PR returns part of the stream name or type, NOT the file extension! 
  - The format is `<filename>:<stream name>:<stream type>`
  - The file name extension for `"foo.exe:bar.txt"` is `"exe"`, not `"txt"`.
- The test needs an explicit check for `"C:file.txt"` since this is the common 
example given in the Jira and here.
- The needs tests for each combination of `<filename>:<stream name>:<stream 
type>`
- Also, with and without driver letters.

Tangent: Note that we also have the class FileSystems for OS-specific 
implementations but it does not have this kind of API.

See [NTFS 
Streams|https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/c54dec26-1551-4d3a-a0ea-4fa40f848eb3]

> Fetching file extension using FilenameUtils.getExtension method throws error 
> in windows machine
> -----------------------------------------------------------------------------------------------
>
>                 Key: IO-783
>                 URL: https://issues.apache.org/jira/browse/IO-783
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.7, 2.8.0, 2.9.0, 2.10.0, 2.11.0
>         Environment: Run the below line of code in windows environment.
> String fileName = FilenameUtils.getExtension("Top of Information 
> Store\\Archive\\Informational-severity alert: eDiscovery search started or 
> exported.msg");
>         System.out.println(fileName);
>  
> We are getting the error,
> Exception in thread "main" java.lang.IllegalArgumentException: NTFS ADS 
> separator (':') in file name is forbidden.
>     at 
> org.apache.commons.io.FilenameUtils.indexOfExtension(FilenameUtils.java:737)
>     at 
> org.apache.commons.io.FilenameUtils.getExtension(FilenameUtils.java:1057)
>            Reporter: Samraj
>            Priority: Major
>
> Hi Team,
> I am using FilenameUtils.getExtension method to get the file extension from 
> the file path ( Available as string). Due to one of the bug fix happen after 
> 2.7 breaks the code. 
> Run the below line of code in windows environment.
> String fileName = FilenameUtils.getExtension("Top of Information 
> Store\\Archive
> Informational-severity alert: eDiscovery search started or exported.msg");
>         System.out.println(fileName);
>  
> We are getting the error,
> Exception in thread "main" java.lang.IllegalArgumentException: NTFS ADS 
> separator (':') in file name is forbidden.
>     at 
> org.apache.commons.io.FilenameUtils.indexOfExtension(FilenameUtils.java:737)
>     at 
> org.apache.commons.io.FilenameUtils.getExtension(FilenameUtils.java:1057)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to