Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8357097

DirectoryStream variant that yields directory entries

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • core-libs
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      It should be possible to get a DirectoryStream<DirectoryEntry> that yields the following record:

      record DirectoryEntry(Path name, EntryType type)
      enum EntryType {
        UNKNOWN,
        REGULAR_FILE,
        DIRECTORY,
        SYMBOLIC_LINK,
        BLOCK_DEVICE,
        CHARACTER_DEVICE,
        FIFO,
        SOCKET,
      };

      The "name" member is of course the name of the directory entry. Unlike the existing DirectoryStream<Path>, though, this Path has only one component; it is not joined to the directory path. This makes it convenient for use with the SecureDirectoryStream APIs, which work best with relative paths. Currently, in a program performing a SecureDirectoryStream action on every entry in a directory, the directory stream receives each entry name from the underlying system call, prepends the directory path to return to the caller, only to immediately have the directory stream user strip the directory path to pass into SecureDirectoryStream. This is wasteful.

      Some operating systems and filesystems return the type of each entry when listing a directory. The "type" member exposes this information to Java. Programs can use it to avoid an extra stat syscall for each entry to learn its type. Systems and filesystems that don't track the type may return UNKNOWN with every entry.


            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: