Exemplo n.º 1
0
 public void copy(Path source, Path target, CopySourceMode sourceMode) throws IOException {
   switch (sourceMode) {
     case FILE:
       Files.copy(resolve(source), resolve(target), StandardCopyOption.REPLACE_EXISTING);
       break;
     case DIRECTORY_CONTENTS_ONLY:
       MoreFiles.copyRecursively(resolve(source), resolve(target));
       break;
     case DIRECTORY_AND_CONTENTS:
       MoreFiles.copyRecursively(resolve(source), resolve(target.resolve(source.getFileName())));
       break;
   }
 }
Exemplo n.º 2
0
 public void createSymLink(Path symLink, Path realFile, boolean force) throws IOException {
   symLink = resolve(symLink);
   if (force) {
     Files.deleteIfExists(symLink);
   }
   if (Platform.detect() == Platform.WINDOWS) {
     if (isDirectory(realFile)) {
       // Creating symlinks to directories on Windows requires escalated privileges. We're just
       // going to have to copy things recursively.
       MoreFiles.copyRecursively(realFile, symLink);
     } else {
       // When sourcePath is relative, resolve it from the targetPath. We're creating a hard link
       // anyway.
       realFile = symLink.getParent().resolve(realFile).normalize();
       Files.createLink(symLink, realFile);
     }
   } else {
     Files.createSymbolicLink(symLink, realFile);
   }
 }