Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-771

FilenameUtils#getFullPathNoEndSeparator - Different behaviour between windows and linux

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.6
    • None
    • Utilities
    • None

    Description

      When using FilenameUtils#getFullPathNoEndSeparator with directories, windows and linux are returning different results.

      Linux returns ".../subfolder" and windows returns "...\path".

          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()));
          }
      

      The result should be equal when using both OS.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sgessner Sita Geßner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: