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

File.getOwner() to retrieve information about file ownership

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      The class java.io.File surprisingly lacks a method named: getOwner

      We can get the size, whether it's a directory, whether it's readable, whether it's writable, the file name, etc. Why not the owner name?

      The signature ought to be: public String getOwner();

      One consideration is that the concept of file ownership differs from system to system, and is absent in some systems. That's handlable.

      Of the systems that have file ownership, they all can retrieve a printable owner name. On Unix where you can have multiple user names for the same user ID, I suggest making the user name returned be the first one found in the password file (or other user name lookup means). If the user name cannot be found or is otherwise unsupported, then return the numerical user ID as a string.

      If file ownership does not exist on the system at all, you can return null. Since you're gauranteed to return a non-null String if the concept of file ownership does exist, then returning null is a clear indication that the concept of file ownership does not exist.

      There might be a hypothetical case to be made for a system that supports multiple file owners. I don't know of such a system, so it's probably much too pedantic a case. Especially since I can't think of a good use for having multiple file owners.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alanb Alan Bateman
                Reporter:
                dherronsunw David Herron (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: