Proposal

Proposal: File Attribute Support in Eclipse

Abstract

The Java file I/O classes do not provide an API for manipulating many advanced attributes found in common file systems, including permissions support beyond read/write access and timestamps including creation time. This proposal is for an extension to the eclipse.core.resources API to add support for manipulating these attributes when they are available.

Background

This feature has been a long-standing request from many Linux developers who require the executable bit to be preserved on copying of projects and on checkout from CVS. An important example is shared object files on platforms where they must be set executable. As well, this problem occurs when unzipping or untarring files.

For more background, see Eclipse bugs 26100, 31303, 25387, and their many duplicates. For an existing workaround for shared libraries on HP-UX, see bug 20305.

Requirements and Design

Based on the above bug reports and investigation into the existing APIs, we decided on the following requirements and design decisions:

  1. Must support the executable bit.
  2. Must support both files and directories.
  3. Need not be part of the copy/create functions, can be a separate call to 'fix' the permissions.
  4. It must be OK for: setResourceAttributes(attributes); getResourceAttributes() != attributes
  5. It should be extensible to support attributes we may require in the future.

Proposed API

We propose the following API:

  1. An interface (IResourceAttributes) which defines get and set methods for all known useful file system attributes.
  2. A default implementation (ResourceAttributes).
  3. A function to set the attributes on a Resource (void setResourceAttributes(IResourceAttributes)).
  4. A function to return the attributes of a Resource (IResourceAttributes getResourceAttributes()).
  5. Native methods under CoreFileSystemLibrary to implement the get and set methods.

One of the advantages to this approach is its extensibility. A possible extension would be the addition of group or world permissions. By providing a default implementation class, we can replace methods with implementations that do something reasonable if group permissions become supported.

Proposed Attributes

We propose the following attributes be supported in the initial implementation:

  1. Execute (Linux)

The following attributes may also be useful additions in the future.

  1. Modification time (mentioned in bug 25387).

Example Implementation

This is a possible implementation of the proposal, contributed by Ben Konrath.

Notes on the Implementation

The following are Ben's notes on his proposed implementation.

Authors

This proposal can be mostly blamed on Ben Konrath, Douglas Pollock, and Billy Biggs.

ChangeLog