Sita Geßner created IO-771:
------------------------------

             Summary: 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


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)

Reply via email to