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

FileUtils.directoryContains returns wrong response due to startsWith comparison

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.4
    • None
    • Utilities
    • None

    Description

      Consider the following:

      File fooDir = new File("/temp/foo");
      File fooFile = new File("/temp/foo.txt");
      FileUtils.directoryContains(fooDir, fooFile); // returns true, should return false
      

      fooFile is a sibling of fooDir. fooDir does not contain fooFile.

      This is due to the way FilenameUtils.directoryContains is implemented in that this method uses a simple 'startsWith' comparison. A related bug is filed for the FilenameUtils method that I believe should be fixed as well.

      Attachments

        Issue Links

          Activity

            People

              krosenvold Kristian Rosenvold
              rnavarette Ray Navarette
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: