JDK-4125893 : FileSystem class to encapsulate the abilities and limitations of a platform
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.2.0,1.2.2
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_2.5.1
  • CPU: generic,sparc
  • Submitted: 1998-04-05
  • Updated: 2009-02-16
  • Resolved: 2009-02-16
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Name: el35337			Date: 04/04/98


This is related to, but significantly more ambitious than, bug
report 4089881.

The current API for dealing with files and directories is limited in
certain frustrating ways.  In particular, the inability to detect or
manipulate symbolic links and/or file permissions/acls is particularly
aggrivating, as is the system-dependent file-creation semantics of
FileOutputStream.

So, I propose that you add a new FileSystem class which encapsulates
the abilities and limitations of a particular file system.  Each
FileDescriptor would have a FileSystem object associated with it.
Subclasses of FileSystem could encapsulate the semantics of DOS,
WinNT, UFS, NFS, AFS, etc.  You also add a bunch of capabilities to
FileDescriptors, so you'd probably wind up dealing in subclassed
FileDescriptors as well -- NFSFileDescriptor, etc.

A user should be able to query a FileSystem object to determine its
capabilities/limitations; the interface should be the union of all
conceivable file system operations, with each throwing a
notImplementedException or somesuch for things it can't actually do.

Things I'd want in the FileSystem class:
variations on the UNIX open command:
- create, read, readwrite, write, append, and truncate, which all
  open a file -- create fails if the file exists already, all the others
  fail if it doesn't.  Each returns a FileDescriptor.  You can then
  feed that FD to FileOutputStream or whatever.
- the same things, with a boolean flag or two indicating SYNC
- the ability to create symbolic links to other parts of the hierarchy
- the ability to query whether or not these things are possible in the
  specified filesystem

Things I'd like added to the FileDescriptor class:
- the ability to set file and directory ownership at a user and group level
- the ability to set file and directory permissions as per AFS (this list
  stolen from MIT Project Athena's OLC answers):
        r       read the contents of files in the directory
        l       list the names of files in the directory
        i       insert files into the directory
        d       delete files from the directory
        w       write (or modify) files into the directory
        k       lock (or modify the write-mode bit) of files in the directory
        a       administer or change the acl of the directory

  I'd like to see r,d,w,k, and a available per-file as well, in the 
  event that some filesystem supports that fine level someday.
- the ability to query which of these ops are possible on this filedescriptor
- the ability to set/unset the lock-bit on a file/directory


Really, the details of these things aren't important, so long as
the abilities get there somehow.  Until then, Java apps can't
share files in a restricted way on shared filesystems.
(Review ID: 27411)
======================================================================

Comments
WORK AROUND Name: tb29552 Date: 01/03/2000 Write JNI interfaces for all operating systems. (Review ID: 99488) ======================================================================
11-06-2004

EVALUATION Yes yes yes yes, but not in JDK 1.2. Maybe in the next feature release. -- mr@eng 4/6/1998
06-04-1998