JDK-4141996 : File - add copy with metadata to handle resource forks, attributes, etc.
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.1.6,1.2.0,1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1998-05-26
  • Updated: 2009-02-16
  • Resolved: 2009-02-16
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Name: rm29839			Date: 05/26/98


This one is simple.  At least two platforms, the BeOS and the MacOS, have file
metadata.  This metadata cannot be copied in a platform independent way,
which makes it very difficult to make a backup copy of a file before writing
the new one.  (I know I can rename the file, but that is not always appropriate,
if I intend to append, rather than rewrite fresh)

In order to do a file copy on the MacOS, I need different code than for the
Windows and Solaris platforms.  It is my expectation that file metadata is
going to get more common, and that a simple, universal method for copying
data would be useful.  If such a method were provided, then it would be up
to the platform vendors to implement it in a way that properly dealt with
resource forks, attributes, and metadata, but the individual developer
would not have to.

Finally, this can cover the issue of permissions on Unix platforms.  If a
program makes a copy of the file, then the permissions and owner
could be copied as well.

Since it is a simple method, the signature would be something like

copy(File destination, boolean overwrite, boolean copyMetadata) throws IOException

overwrite is not all that needed, since it is not that hard to check for
existence first, and, in my mind, copyMetadata should be the default
behavior all of the time, but some may complain that they do not
always want all permissions, etc. to be copied.

Scott
(Review ID: 29718)
======================================================================

Name: skT88420			Date: 02/03/2000


java version "1.1.6"

While trying to copyfiles, the developer has to use the read/write methods on
files. This results in the destination having the latest timestamp as opposed to
that of the original file.
We need a mechanism that essentially results in a filecopy.
(Review ID: 100727)
======================================================================

Comments
EVALUATION This feature has been addressed by the new file system API defined by JSR-203. The Path.copyTo method may be invoked with the COPY_ATTRIBUTES option that will attempt to copy all the file metadata including named streams.
16-02-2009

WORK AROUND Name: rm29839 Date: 05/26/98 The only workarounds are platform specific, which is the complaint. JConfig apparently has some cross platform solutions, but is not a part of the standard API, and may have licesnsing issues. ====================================================================== Name: tb29552 Date: 01/03/2000 JNI (Review ID: 99490) ====================================================================== Name: skT88420 Date: 02/03/2000 The only (unacceptable) workaround is to have native implementation for copying files. (Review ID: 100727) ======================================================================
11-06-2004