< prev index next >

src/solaris/classes/sun/nio/fs/UnixCopyFile.java

Print this page
rev 8219 : 8024900: PPC64: Enable new build on AIX (jdk part)
8024854: PPC64: Basic changes and files to build the class library on AIX
Reviewed-by: alanb, prr, sla, chegar, michaelm, mullan, art, erikj
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com


 173                 }
 174             }
 175             // copy other attributes
 176             if (flags.copyNonPosixAttributes && (dfd >= 0)) {
 177                 int sfd = -1;
 178                 try {
 179                     sfd = open(source, O_RDONLY, 0);
 180                 } catch (UnixException x) {
 181                     if (flags.failIfUnableToCopyNonPosix)
 182                         x.rethrowAsIOException(source);
 183                 }
 184                 if (sfd >= 0) {
 185                     source.getFileSystem().copyNonPosixAttributes(sfd, dfd);
 186                     close(sfd);
 187                 }
 188             }
 189             // copy time stamps last
 190             if (flags.copyBasicAttributes) {
 191                 try {
 192                     if (dfd >= 0) {

 193                         futimes(dfd,
 194                                 attrs.lastAccessTime().to(TimeUnit.MICROSECONDS),
 195                                 attrs.lastModifiedTime().to(TimeUnit.MICROSECONDS));

 196                     } else {
 197                         utimes(target,
 198                                attrs.lastAccessTime().to(TimeUnit.MICROSECONDS),
 199                                attrs.lastModifiedTime().to(TimeUnit.MICROSECONDS));
 200                     }
 201                 } catch (UnixException x) {
 202                     // unable to set times
 203                     if (flags.failIfUnableToCopyBasic)
 204                         x.rethrowAsIOException(target);
 205                 }
 206             }
 207             done = true;
 208         } finally {
 209             if (dfd >= 0)
 210                 close(dfd);
 211             if (!done) {
 212                 // rollback
 213                 try { rmdir(target); } catch (UnixException ignore) { }
 214             }
 215         }


 252                 } catch (UnixException x) {
 253                     x.rethrowAsIOException(source, target);
 254                 }
 255                 // copy owner/permissions
 256                 if (flags.copyPosixAttributes) {
 257                     try {
 258                         fchown(fo, attrs.uid(), attrs.gid());
 259                         fchmod(fo, attrs.mode());
 260                     } catch (UnixException x) {
 261                         if (flags.failIfUnableToCopyPosix)
 262                             x.rethrowAsIOException(target);
 263                     }
 264                 }
 265                 // copy non POSIX attributes (depends on file system)
 266                 if (flags.copyNonPosixAttributes) {
 267                     source.getFileSystem().copyNonPosixAttributes(fi, fo);
 268                 }
 269                 // copy time attributes
 270                 if (flags.copyBasicAttributes) {
 271                     try {

 272                         futimes(fo,
 273                                 attrs.lastAccessTime().to(TimeUnit.MICROSECONDS),
 274                                 attrs.lastModifiedTime().to(TimeUnit.MICROSECONDS));

 275                     } catch (UnixException x) {
 276                         if (flags.failIfUnableToCopyBasic)
 277                             x.rethrowAsIOException(target);
 278                     }
 279                 }
 280                 complete = true;
 281             } finally {
 282                 close(fo);
 283 
 284                 // copy of file or attributes failed so rollback
 285                 if (!complete) {
 286                     try {
 287                         unlink(target);
 288                     } catch (UnixException ignore) { }
 289                 }
 290             }
 291         } finally {
 292             close(fi);
 293         }
 294     }




 173                 }
 174             }
 175             // copy other attributes
 176             if (flags.copyNonPosixAttributes && (dfd >= 0)) {
 177                 int sfd = -1;
 178                 try {
 179                     sfd = open(source, O_RDONLY, 0);
 180                 } catch (UnixException x) {
 181                     if (flags.failIfUnableToCopyNonPosix)
 182                         x.rethrowAsIOException(source);
 183                 }
 184                 if (sfd >= 0) {
 185                     source.getFileSystem().copyNonPosixAttributes(sfd, dfd);
 186                     close(sfd);
 187                 }
 188             }
 189             // copy time stamps last
 190             if (flags.copyBasicAttributes) {
 191                 try {
 192                     if (dfd >= 0) {
 193                         // Added path of file "dfd" for platform ports (only needed on AIX and HPUX)
 194                         futimes(dfd,
 195                                 attrs.lastAccessTime().to(TimeUnit.MICROSECONDS),
 196                                 attrs.lastModifiedTime().to(TimeUnit.MICROSECONDS),
 197                                 target);
 198                     } else {
 199                         utimes(target,
 200                                attrs.lastAccessTime().to(TimeUnit.MICROSECONDS),
 201                                attrs.lastModifiedTime().to(TimeUnit.MICROSECONDS));
 202                     }
 203                 } catch (UnixException x) {
 204                     // unable to set times
 205                     if (flags.failIfUnableToCopyBasic)
 206                         x.rethrowAsIOException(target);
 207                 }
 208             }
 209             done = true;
 210         } finally {
 211             if (dfd >= 0)
 212                 close(dfd);
 213             if (!done) {
 214                 // rollback
 215                 try { rmdir(target); } catch (UnixException ignore) { }
 216             }
 217         }


 254                 } catch (UnixException x) {
 255                     x.rethrowAsIOException(source, target);
 256                 }
 257                 // copy owner/permissions
 258                 if (flags.copyPosixAttributes) {
 259                     try {
 260                         fchown(fo, attrs.uid(), attrs.gid());
 261                         fchmod(fo, attrs.mode());
 262                     } catch (UnixException x) {
 263                         if (flags.failIfUnableToCopyPosix)
 264                             x.rethrowAsIOException(target);
 265                     }
 266                 }
 267                 // copy non POSIX attributes (depends on file system)
 268                 if (flags.copyNonPosixAttributes) {
 269                     source.getFileSystem().copyNonPosixAttributes(fi, fo);
 270                 }
 271                 // copy time attributes
 272                 if (flags.copyBasicAttributes) {
 273                     try {
 274                         // Added path of file "fo" for platform ports (only needed on AIX and HPUX)
 275                         futimes(fo,
 276                                 attrs.lastAccessTime().to(TimeUnit.MICROSECONDS),
 277                                 attrs.lastModifiedTime().to(TimeUnit.MICROSECONDS),
 278                                 target);
 279                     } catch (UnixException x) {
 280                         if (flags.failIfUnableToCopyBasic)
 281                             x.rethrowAsIOException(target);
 282                     }
 283                 }
 284                 complete = true;
 285             } finally {
 286                 close(fo);
 287 
 288                 // copy of file or attributes failed so rollback
 289                 if (!complete) {
 290                     try {
 291                         unlink(target);
 292                     } catch (UnixException ignore) { }
 293                 }
 294             }
 295         } finally {
 296             close(fi);
 297         }
 298     }


< prev index next >