| Proposal |
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.
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.
Based on the above bug reports and investigation into the existing APIs, we decided on the following requirements and design decisions:
We propose the following API:
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.
We propose the following attributes be supported in the initial implementation:
The following attributes may also be useful additions in the future.
This is a possible implementation of the proposal, contributed by Ben Konrath.
The following are Ben's notes on his proposed implementation.
It could, but do we want it to? setReadOnly() is not platform specific and is suported by Java. It seems that the setReadOnly stuff uses the native implementation if it's available and if not it uses Java methods. What's the reason for this? I thought it would be better to use the Java version over the native. Maybe this is a speed issue? Dunno.
My opinion on this is that get/setAttributes should only be use for platform specific attributes that are not supported by Java. If the attributes become supported with a future version of Java, then a moving over to a pure Java solution should be considered.
When setting or getting the execute attribute, only the owner is set or checked for +x. This means that the cvs plugin may not check out files with the exact permissions as the file has on the server. The cvs plugin will always checkin files ugo+x. I am not sure if this is correct approach.
The RPM plugin will not be using this interface because there already exists a method copy(...) in FileSystemStore.java that will copy files with attributes. I still have to see if these will work with the RPM plugin. If they don't, the new ResourceAttributes would have to accommodate group and other for the RPM plugin to use it. This is because the RPM plugin needs to do a recursive copy preserving the all of permission bits.
I had to compile core.c manually becuase I was getting some include errors. The commands I used were:
gcc -fPIC -g -c -I/opt/j2sdk1.4.2_05/include/linux -I/opt/j2sdk1.4.2_05/include core.c -o core.o gcc -g -shared -Wl,-soname,libcore.so -o libcore_3_1_0.so core.o -lc
This proposal can be mostly blamed on Ben Konrath, Douglas Pollock, and Billy Biggs.