You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sita Geßner (Jira)" <ji...@apache.org> on 2022/05/17 12:14:00 UTC
[jira] [Updated] (IO-771) FilenameUtils#getFullPathNoEndSeparator - Different behaviour between windows and linux
[ https://issues.apache.org/jira/browse/IO-771?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sita Geßner updated IO-771:
---------------------------
Description:
When using FilenameUtils#getFullPathNoEndSeparator with directories, windows and linux are returning different results.
Linux returns ".../subfolder" and windows returns "...\path".
{code:java}
private static void commonsIo() {
String result = getSubFolderFromFile(new File("C:\\path\\subfolder\\"));
// Fails in common-io:2.11.0 b/c result is "path" instead of "subfolder".
System.out.println("result should be \"subfolder\", but it is: " + result);
}
private static String getSubFolderFromFile(final File file) {
return FilenameUtils.getBaseName(FilenameUtils.getFullPathNoEndSeparator(file.getAbsolutePath()));
}
{code}
The result should be equal when using both OS.
was:
When using FilenameUtils#getFullPathNoEndSeparator with directories, windows and linux are returning different results.
Linux returns ".../subfolder" and windows returns "...\path".
{code:java}
private static void commonsIo() {
String result = getSubFolderFromFile(new File("C:\\path\\subfolder\\"));
// Fails in common-io:2.11.0 b/c result is "path" instead of "subfolder".
System.out.println("result should be \"subfolder\", but it is: " + result);
}
private static String getSubFolderFromFile(final File file) {
return FilenameUtils.getBaseName(FilenameUtils.getFullPathNoEndSeparator(file.getAbsolutePath()));
}
{code}
The result should be equal when using both OS.
> FilenameUtils#getFullPathNoEndSeparator - Different behaviour between windows and linux
> ---------------------------------------------------------------------------------------
>
> Key: IO-771
> URL: https://issues.apache.org/jira/browse/IO-771
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.6
> Reporter: Sita Geßner
> Priority: Minor
>
> When using FilenameUtils#getFullPathNoEndSeparator with directories, windows and linux are returning different results.
> Linux returns ".../subfolder" and windows returns "...\path".
> {code:java}
> private static void commonsIo() {
> String result = getSubFolderFromFile(new File("C:\\path\\subfolder\\"));
> // Fails in common-io:2.11.0 b/c result is "path" instead of "subfolder".
> System.out.println("result should be \"subfolder\", but it is: " + result);
> }
> private static String getSubFolderFromFile(final File file) {
> return FilenameUtils.getBaseName(FilenameUtils.getFullPathNoEndSeparator(file.getAbsolutePath()));
> }
> {code}
> The result should be equal when using both OS.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)