Java Examples for java.nio.file.CopyOption
The following java examples will help you to understand the usage of java.nio.file.CopyOption. These source code samples are taken from different open source projects.
Example 1
| Project: jbosstools-integration-stack-tests-master File: FileUtils.java View source code |
/**
* Copy given directory, sub-directories and files
*
* @param from
* a file system path to the 'from' directory
* @param to
* a file system path to the destination
* @throws IOException
*/
public static void copyDirectory(String fromPath, String toPath) throws IOException {
Path from = Paths.get(fromPath);
Path to = Paths.get(toPath);
CopyOption[] options = new CopyOption[] { StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES };
Files.copy(from, to, options);
for (File item : from.toFile().listFiles()) {
if (item.isDirectory()) {
copyDirectory(item.toString(), toPath + File.separator + item.getName());
} else {
Files.copy(Paths.get(item.toString()), Paths.get(toPath + File.separator + item.getName()), options);
}
}
}Example 2
| Project: Web-Karma-master File: AbstractFileDistributionStrategy.java View source code |
@Override
public void prepare(@SuppressWarnings("rawtypes") Map globalConfig) {
try {
tempDirPath = Files.createTempDirectory("karma_home", new FileAttribute[0]);
File tempDir = tempDirPath.toFile();
tempDir.deleteOnExit();
InputStream serializedFileStream = getStream();
if (isZipped) {
ZipUtil.unpack(serializedFileStream, tempDir);
materializedFilePath = FileSystems.getDefault().getPath(tempDir.getAbsolutePath(), "karma");
} else {
Path filePath = FileSystems.getDefault().getPath(tempDir.getAbsolutePath(), fileName);
Files.copy(serializedFileStream, filePath, new CopyOption[0]);
materializedFilePath = filePath;
}
LOG.info("Materialized file at: " + materializedFilePath.toAbsolutePath());
} catch (Exception e) {
LOG.error("Unable to materialize file: " + fileName, e);
}
}Example 3
| Project: Giraffe-master File: SshFileSystemProvider.java View source code |
@Override
public void copy(Path source, Path target, CopyOption... options) throws IOException {
SshPath sourceFile = checkPath(source);
SshPath targetFile = checkPath(target);
CopyFlags flags = CopyFlags.fromOptions(options);
if (!Files.isSameFile(sourceFile, targetFile)) {
if (Files.isDirectory(sourceFile, LinkOptions.toArray(flags.followLinks))) {
logger(sourceFile).debug("copying directory {} to {}", source, target.toUri());
copyDirectory(sourceFile, targetFile, flags);
} else if (isSameUri(sourceFile, targetFile)) {
logger(sourceFile).debug("copying file {} to {}", source, target);
SshSameHostFileHelper.copyFile(sourceFile, targetFile, flags);
} else {
logger(sourceFile).debug("copying file {} to {}", source, target.toUri());
CrossSystemTransfers.copyFile(sourceFile, targetFile, flags);
}
}
}Example 4
| Project: NearInfinity-master File: FileResourceEntry.java View source code |
public void renameFile(String newName, boolean overwrite) throws IOException {
Path basePath = file.getParent();
CopyOption[] options = new CopyOption[overwrite ? 2 : 1];
options[0] = StandardCopyOption.ATOMIC_MOVE;
if (overwrite) {
options[1] = StandardCopyOption.REPLACE_EXISTING;
}
file = Files.move(file, basePath.resolve(newName), options);
}Example 5
| Project: liferay-ide-master File: IOUtil.java View source code |
private void copyFile(Path source, Path target) {
CopyOption[] options = new CopyOption[] { StandardCopyOption.REPLACE_EXISTING };
try {
File folder = target.toFile().getParentFile();
if (!folder.exists()) {
folder.mkdirs();
}
Files.copy(source, target, options);
} catch (IOException e) {
LiferayCore.logError("copy file " + source.toFile().getName() + " error", e);
}
}Example 6
| Project: incubator-taverna-language-master File: RecursiveCopyFileVisitor.java View source code |
public static void copyRecursively(final Path source, final Path destination, final CopyOption... copyOptions) throws IOException { final Set<CopyOption> copyOptionsSet = new HashSet<>(Arrays.asList(copyOptions)); if (!isDirectory(source)) throw new FileNotFoundException("Not a directory: " + source); if (isDirectory(destination) && !copyOptionsSet.contains(REPLACE_EXISTING)) throw new FileAlreadyExistsException(destination.toString()); Path destinationParent = destination.getParent(); if (destinationParent != null && !isDirectory(destinationParent)) throw new FileNotFoundException("Not a directory: " + destinationParent); RecursiveCopyFileVisitor visitor = new RecursiveCopyFileVisitor(destination, copyOptionsSet, source); Set<FileVisitOption> walkOptions = noneOf(FileVisitOption.class); if (!copyOptionsSet.contains(NOFOLLOW_LINKS)) walkOptions = EnumSet.of(FOLLOW_LINKS); walkFileTree(source, walkOptions, MAX_VALUE, visitor); }
Example 7
| Project: gemini.web.gemini-web-container-master File: DirTransformer.java View source code |
private void transformFile(Path fromFile, Path toFile) throws IOException {
boolean transformed = false;
try (InputStream fis = Files.newInputStream(fromFile)) {
transformed = this.callback.transformFile(fis, toFile);
}
if (!transformed) {
Files.createDirectories(toFile.getParent());
Files.copy(fromFile, toFile, new CopyOption[] { StandardCopyOption.REPLACE_EXISTING });
}
}Example 8
| Project: heron-master File: LocalFileSystemUploader.java View source code |
/**
* Upload the topology package to the destined location in local file system
*
* @return destination URI of where the topology package has
* been uploaded if successful, or {@code null} if failed.
*/
@Override
public URI uploadPackage() throws UploaderException {
// first, check if the topology package exists
boolean fileExists = new File(topologyPackageLocation).isFile();
if (!fileExists) {
throw new UploaderException(String.format("Topology package does not exist at '%s'", topologyPackageLocation));
}
// get the directory containing the file
Path filePath = Paths.get(destTopologyFile);
File parentDirectory = filePath.getParent().toFile();
assert parentDirectory != null;
// if the dest directory does not exist, create it.
if (!parentDirectory.exists()) {
LOG.fine(String.format("Working directory does not exist. Creating it now at %s", parentDirectory.getPath()));
if (!parentDirectory.mkdirs()) {
throw new UploaderException(String.format("Failed to create directory for topology package at %s", parentDirectory.getPath()));
}
}
// if the dest file exists, write a log message
fileExists = new File(filePath.toString()).isFile();
if (fileExists) {
LOG.fine(String.format("Target topology package already exists at '%s'. Overwriting it now", filePath.toString()));
}
// copy the topology package to target working directory
LOG.fine(String.format("Copying topology package at '%s' to target working directory '%s'", topologyPackageLocation, filePath.toString()));
Path source = Paths.get(topologyPackageLocation);
try {
CopyOption[] options = new CopyOption[] { StandardCopyOption.REPLACE_EXISTING };
Files.copy(source, filePath, options);
} catch (IOException e) {
throw new UploaderException(String.format("Unable to copy topology file from '%s' to '%s'", source, filePath), e);
}
return getUri(destTopologyFile);
}Example 9
| Project: JFramework-master File: SingleThreadScreenshotProcessor.java View source code |
private void moveScreenshot(QueuedScreenshot queuedScreenshot) {
try {
CopyOption[] options = new CopyOption[] { StandardCopyOption.COPY_ATTRIBUTES };
Path sourcePath = queuedScreenshot.getSourceFile().toPath();
Path destinationPath = queuedScreenshot.getDestinationFile().toPath();
Path destinationDir = queuedScreenshot.getDestinationFile().toPath().getParent();
if (Files.notExists(destinationDir)) {
Files.createDirectories(destinationDir);
}
if (Files.notExists(destinationPath)) {
Files.copy(sourcePath, destinationPath, options);
}
try {
Files.deleteIfExists(sourcePath);
} catch (IOException e) {
queuedScreenshot.getSourceFile().deleteOnExit();
}
} catch (Throwable e) {
logger.warn("Failed to copy the screenshot to the destination directory: " + e.getMessage());
}
}Example 10
| Project: snoozenode-master File: LocalBackingImageManager.java View source code |
@Override
public boolean fetchImage(VirtualMachineMetaData virtualMachine) {
int exitCode = 0;
VirtualMachineImage image = virtualMachine.getImage();
String sourcePath = source_ + "/" + virtualMachine.getImage().getName();
String destinationDirectory = destination_;
String destinationPathMaster = destinationDirectory + "/" + image.getName();
String destinationPathSlave = destinationDirectory + "/" + virtualMachine.getVirtualMachineLocation().getVirtualMachineId();
try {
if (!cache_.contains(image.getName())) {
log_.debug(String.format("copying the master file from %s to %s", sourcePath, destinationPathMaster));
Path from = Paths.get(sourcePath);
Path to = Paths.get(destinationPathMaster);
//overwrite existing file, if exists
CopyOption[] options = new CopyOption[] { StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES };
Files.copy(from, to, options);
log_.debug("Master file copied");
}
log_.debug("creating the snapshot");
String command = String.format("qemu-img create -b %s -f qcow2 %s", destinationPathMaster, destinationPathSlave);
log_.debug("executing command : " + command);
Process process = Runtime.getRuntime().exec(command);
exitCode = process.waitFor();
} catch (IOException e) {
log_.error("Failed to fetch vm image disk " + e.getMessage());
return false;
} catch (InterruptedException e) {
log_.error("Failed to fecth vm image disk " + e.getMessage());
return false;
}
if (exitCode == 0) {
cache_.add(image.getName());
virtualMachine.getImage().setPath(destinationPathSlave);
virtualMachine.getImage().setFormat("qcow2");
return true;
}
log_.error("Failed to fetch vm image disk");
return false;
}Example 11
| Project: thucydides-master File: SingleThreadScreenshotProcessor.java View source code |
private void moveScreenshot(QueuedScreenshot queuedScreenshot) {
try {
CopyOption[] options = new CopyOption[] { StandardCopyOption.COPY_ATTRIBUTES };
Path sourcePath = queuedScreenshot.getSourceFile().toPath();
Path destinationPath = queuedScreenshot.getDestinationFile().toPath();
Path destinationDir = queuedScreenshot.getDestinationFile().toPath().getParent();
if (Files.notExists(destinationDir)) {
Files.createDirectories(destinationDir);
}
if (Files.notExists(destinationPath)) {
Files.copy(sourcePath, destinationPath, options);
}
try {
Files.deleteIfExists(sourcePath);
} catch (IOException e) {
queuedScreenshot.getSourceFile().deleteOnExit();
}
} catch (Throwable e) {
logger.warn("Failed to copy the screenshot to the destination directory: " + e.getMessage());
}
}Example 12
| Project: shrinkwrap-master File: ShrinkWrapFileSystemProvider.java View source code |
/**
* {@inheritDoc}
*
* @see java.nio.file.spi.FileSystemProvider#move(java.nio.file.Path, java.nio.file.Path,
* java.nio.file.CopyOption[])
*/
@Override
public void move(final Path source, final Path target, final CopyOption... options) throws IOException {
// Precondition checks
if (source == null) {
throw new IllegalArgumentException("source must be specified");
}
if (target == null) {
throw new IllegalArgumentException("target must be specified");
}
// Source exists?
if (!Files.exists(source, new LinkOption[] {})) {
throw new IllegalArgumentException("Source file doesn't exist: " + source.toString());
}
// If equal, NOOP
if (source == target) {
return;
}
final Archive<?> archive = this.getArchive(target);
final Node node = archive.get(target.toString());
// Copying to something already present?
if (node != null) {
final Asset asset = node.getAsset();
// Directory
if (asset == null) {
// Not empty
if (node.getChildren().size() > 0) {
throw new DirectoryNotEmptyException("Cannot move to non-empty directory: " + target.toString());
}
}
}
// Move
archive.move(source.toString(), target.toString());
}Example 13
| Project: agui_eclipse_plugin-master File: ResourceBuilder.java View source code |
protected void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) throws CoreException {
// the visitor does the work.
delta.accept(new SampleDeltaVisitor());
final IProject project = delta.getResource().getProject();
if (BaseProjectHelper.isAguiProject(project)) {
// get AguiManifest info
AguiProjectInfo aguiInfo = BaseProjectHelper.getAguiProjectInfo(project);
// BuildConfig.java
AguiProjectMaker maker = new AguiProjectMaker(aguiInfo.projectName, aguiInfo.packageName, aguiInfo.mainActivityName);
try (BufferedInputStream buildConfigBis = new BufferedInputStream(maker.copyTemplate("BuildConfigTemplate.txt"))) {
Files.copy(buildConfigBis, Paths.get(aguiInfo.projectPath, "gen", aguiInfo.packageName.replace(".", "/"), AguiConstants.BUILD_CONFIG_JAVA), new CopyOption[] { StandardCopyOption.REPLACE_EXISTING });
} catch (IOException e) {
e.printStackTrace();
AguiPlugin.displayError("Build Error", e.getMessage());
}
// R.java
String aguiCorePackageName = thahn.java.agui.Main.class.getPackage().getName();
String aguiCorePath = AguiPrefs.getInstance().getSdkJarLocation();
// prepare resource container like enum resource, etc..
RMaker coreRMaker = new RMaker(true, aguiCorePackageName, aguiCorePath, aguiCorePath, aguiCorePath, ResourcesManager.getInstance(), aguiCorePackageName);
coreRMaker.parse();
// make R.java
RBuilder rBuilder = new RBuilder(aguiCorePackageName, aguiCorePath, aguiInfo.packageName, aguiInfo.projectPath);
rBuilder.parse();
// refresh
IFolder genFolder = project.getFolder(AguiConstants.FD_GEN);
genFolder.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 10));
}
}Example 14
| Project: jimfs-master File: FileSystemView.java View source code |
/**
* Copies or moves the file at the given source path to the given dest path.
*/
public void copy(JimfsPath source, FileSystemView destView, JimfsPath dest, Set<CopyOption> options, boolean move) throws IOException {
checkNotNull(source);
checkNotNull(destView);
checkNotNull(dest);
checkNotNull(options);
boolean sameFileSystem = isSameFileSystem(destView);
File sourceFile;
// non-null after block completes iff source file was copied
File copyFile = null;
lockBoth(store.writeLock(), destView.store.writeLock());
try {
DirectoryEntry sourceEntry = lookUp(source, options).requireExists(source);
DirectoryEntry destEntry = destView.lookUp(dest, Options.NOFOLLOW_LINKS);
Directory sourceParent = sourceEntry.directory();
sourceFile = sourceEntry.file();
Directory destParent = destEntry.directory();
if (move && sourceFile.isDirectory()) {
if (sameFileSystem) {
checkMovable(sourceFile, source);
checkNotAncestor(sourceFile, destParent, destView);
} else {
// move to another file system is accomplished by copy-then-delete, so the source file
// must be deletable to be moved
checkDeletable(sourceFile, DeleteMode.ANY, source);
}
}
if (destEntry.exists()) {
if (destEntry.file().equals(sourceFile)) {
return;
} else if (options.contains(REPLACE_EXISTING)) {
destView.delete(destEntry, DeleteMode.ANY, dest);
} else {
throw new FileAlreadyExistsException(dest.toString());
}
}
if (move && sameFileSystem) {
// Real move on the same file system.
sourceParent.unlink(source.name());
sourceParent.updateModifiedTime();
destParent.link(dest.name(), sourceFile);
destParent.updateModifiedTime();
} else {
// Doing a copy OR a move to a different file system, which must be implemented by copy and
// delete.
// By default, don't copy attributes.
AttributeCopyOption attributeCopyOption = AttributeCopyOption.NONE;
if (move) {
// Copy only the basic attributes of the file to the other file system, as it may not
// support all the attribute views that this file system does. This also matches the
// behavior of moving a file to a foreign file system with a different
// FileSystemProvider.
attributeCopyOption = AttributeCopyOption.BASIC;
} else if (options.contains(COPY_ATTRIBUTES)) {
// As with move, if we're copying the file to a different file system, only copy its
// basic attributes.
attributeCopyOption = sameFileSystem ? AttributeCopyOption.ALL : AttributeCopyOption.BASIC;
}
// Copy the file, but don't copy its content while we're holding the file store locks.
copyFile = destView.store.copyWithoutContent(sourceFile, attributeCopyOption);
destParent.link(dest.name(), copyFile);
destParent.updateModifiedTime();
// In order for the copy to be atomic (not strictly necessary, but seems preferable since
// we can) lock both source and copy files before leaving the file store locks. This
// ensures that users cannot observe the copy's content until the content has been copied.
// This also marks the source file as opened, preventing its content from being deleted
// until after it's copied if the source file itself is deleted in the next step.
lockSourceAndCopy(sourceFile, copyFile);
if (move) {
// It should not be possible for delete to throw an exception here, because we already
// checked that the file was deletable above.
delete(sourceEntry, DeleteMode.ANY, source);
}
}
} finally {
destView.store.writeLock().unlock();
store.writeLock().unlock();
}
if (copyFile != null) {
// different threads.
try {
sourceFile.copyContentTo(copyFile);
} finally {
// Unlock the files, allowing the content of the copy to be observed by the user. This also
// closes the source file, allowing its content to be deleted if it was deleted.
unlockSourceAndCopy(sourceFile, copyFile);
}
}
}Example 15
| Project: memoryfilesystem-master File: MemoryFileSystem.java View source code |
void copyOrMove(AbstractPath source, AbstractPath target, TwoPathOperation operation, CopyOption... options) throws IOException {
try (AutoRelease autoRelease = autoRelease(this.pathOrderingLock.writeLock())) {
EndPointCopyContext sourceContext = this.buildEndpointCopyContext(source);
EndPointCopyContext targetContext = this.buildEndpointCopyContext(target);
int order = this.orderPaths(sourceContext, targetContext);
final CopyContext copyContext = buildCopyContext(sourceContext, targetContext, operation, options, order);
AbstractPath firstParent = copyContext.first.parent;
final AbstractPath secondParent = copyContext.second.parent;
if (firstParent == null && secondParent == null) {
// simply ignore
return;
}
if (firstParent == null || secondParent == null) {
// only one of the involved paths is a root
throw new FileSystemException(toStringOrNull(firstParent), toStringOrNull(secondParent), "can't copy or move root directory");
}
MemoryDirectory firstRoot = this.getRootDirectory(copyContext.first.path);
final MemoryDirectory secondRoot = this.getRootDirectory(copyContext.second.path);
this.withWriteLockOnLastDo(firstRoot, firstParent, copyContext.firstFollowSymLinks, new MemoryDirectoryBlock<Void>() {
@Override
public Void value(final MemoryDirectory firstDirectory) throws IOException {
MemoryFileSystem.this.withWriteLockOnLastDo(secondRoot, secondParent, copyContext.secondFollowSymLinks, new MemoryDirectoryBlock<Void>() {
@Override
public Void value(MemoryDirectory secondDirectory) throws IOException {
handleTwoPathOperation(copyContext, firstDirectory, secondDirectory);
return null;
}
});
return null;
}
});
}
}Example 16
| Project: nio-fs-provider-master File: WebdavFileSystemProvider.java View source code |
@Override
public void copy(Path fileFrom, Path fileTo, CopyOption... options) throws IOException {
if (!(fileFrom instanceof WebdavPath)) {
throw new IllegalArgumentException(fileFrom.toString());
}
if (!(fileTo instanceof WebdavPath)) {
throw new IllegalArgumentException(fileTo.toString());
}
WebdavPath wPathTo = (WebdavPath) fileTo;
WebdavFileSystem webdavHost = (WebdavFileSystem) fileTo.getFileSystem();
Sardine webdav = webdavHost.getSardine();
webdav.put(wPathTo.toUri().toString(), Files.readAllBytes(fileFrom));
}Example 17
| Project: p2-installer-master File: FileUtils.java View source code |
/**
* Copies source directory to target and preserves attributes. Any existing files will be replaced.
* Links will be followed.
*
* @param source Path of source directory
* @param target Path of target directory
* @param replace <code>true</code> to replace already existing target directory
* @throws IOException on failure
*/
public static void copyDirectory(Path source, Path target, boolean replace) throws IOException {
CopyOption[] options = (replace) ? new CopyOption[] { StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING } : new CopyOption[] { StandardCopyOption.COPY_ATTRIBUTES };
// Follow links during copy.
EnumSet<FileVisitOption> opts = EnumSet.of(FileVisitOption.FOLLOW_LINKS);
FilesCopier tc = new FilesCopier(source, target, options);
Files.walkFileTree(source, opts, Integer.MAX_VALUE, tc);
}Example 18
| Project: roda-master File: FSUtils.java View source code |
/**
* Moves a directory/file from one path to another
*
* @param sourcePath
* source path
* @param targetPath
* target path
* @param replaceExisting
* true if the target directory/file should be replaced if it already
* exists; false otherwise
* @throws AlreadyExistsException
* @throws GenericException
* @throws NotFoundException
*
*/
public static void move(final Path sourcePath, final Path targetPath, boolean replaceExisting) throws AlreadyExistsException, GenericException, NotFoundException {
// check if we can replace existing
if (!replaceExisting && FSUtils.exists(targetPath)) {
throw new AlreadyExistsException("Cannot copy because target path already exists: " + targetPath);
}
// ensure parent directory exists or can be created
try {
if (targetPath != null) {
Files.createDirectories(targetPath.getParent());
}
} catch (FileAlreadyExistsException e) {
} catch (IOException e) {
throw new GenericException("Error while creating target directory parent folder", e);
}
CopyOption[] copyOptions = replaceExisting ? new CopyOption[] { StandardCopyOption.REPLACE_EXISTING } : new CopyOption[] {};
if (FSUtils.isDirectory(sourcePath)) {
try {
Files.move(sourcePath, targetPath, copyOptions);
} catch (DirectoryNotEmptyException e) {
LOGGER.debug("Moving recursively, as a fallback & instead of a simple move, from {} to {}", sourcePath, targetPath);
moveRecursively(sourcePath, targetPath, replaceExisting);
} catch (IOException e) {
throw new GenericException("Error while moving directory from " + sourcePath + " to " + targetPath, e);
}
} else {
try {
Files.move(sourcePath, targetPath, copyOptions);
} catch (NoSuchFileException e) {
throw new NotFoundException("Could not find resource to move", e);
} catch (IOException e) {
throw new GenericException("Error while copying one file into another", e);
}
}
}Example 19
| Project: sonarlint-eclipse-master File: SonarTestCase.java View source code |
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
// before visiting entries in a directory we copy the directory
// (okay if directory already exists).
CopyOption[] options = (preserve) ? new CopyOption[] { COPY_ATTRIBUTES } : new CopyOption[0];
Path newdir = target.resolve(source.relativize(dir));
try {
Files.copy(dir, newdir, options);
} catch (FileAlreadyExistsException x) {
} catch (IOException x) {
System.err.format("Unable to create: %s: %s%n", newdir, x);
return SKIP_SUBTREE;
}
return CONTINUE;
}Example 20
| Project: Starbound-Mod-Manager-master File: FileCopier.java View source code |
/**
* Copy source file to target location. If {@code prompt} is true then
* prompt user to overwrite target if it exists. The {@code preserve}
* parameter determines if file attributes should be copied/preserved.
*/
private static void copyFile(Path source, Path target, boolean prompt, boolean preserve) {
CopyOption[] options = (preserve) ? new CopyOption[] { COPY_ATTRIBUTES, REPLACE_EXISTING } : new CopyOption[] { REPLACE_EXISTING };
try {
Files.createDirectories(target.getParent());
} catch (IOException e) {
e.printStackTrace();
}
try {
Files.copy(source, target, options);
} catch (IOException x) {
log.error(String.format("Unable to copy: %s: %n", source), x);
}
}Example 21
| Project: structr-master File: StructrDOMNodePath.java View source code |
@Override
public void move(final Path target, final CopyOption... options) throws IOException {
if (target instanceof StructrDOMNodePath) {
final App app = StructrApp.getInstance(fs.getSecurityContext());
final StructrDOMNodePath targetPath = (StructrDOMNodePath) target;
try (final Tx tx = app.tx()) {
if (targetPath.parentNode != null && targetPath.parentNode.getUuid().equals(parentNode.getUuid())) {
final String targetName = target.getFileName().toString();
final ElementName targetElementName = new ElementName(targetName);
final ElementName sourceElementName = new ElementName(name);
if (targetElementName.getTagName().equals(sourceElementName.getTagName())) {
final int newPosition = targetElementName.getPosition();
// remove child from current position
parentNode.removeChild(domNode);
// insert at new position
insertDOMNodeAt(domNode, newPosition);
} else {
throw new InvalidPathException(targetName, "Cannot change element type.");
}
} else {
}
tx.success();
} catch (FrameworkException fex) {
logger.warn("Unable to move {} to {}: {}", new Object[] { this, target, fex.getMessage() });
}
} else if (target instanceof StructrNonexistingComponentPath & domNode != null) {
// don't move is source node is not a shared component (allow rename but not move)
if (!(domNode.getOwnerDocument() instanceof ShadowDocument)) {
throw new AccessDeniedException("Cannot move DOM node to shared components");
} else {
final String targetName = target.getFileName().toString();
final int pos = targetName.indexOf("-");
String componentName = null;
String componentTag = null;
if (pos == -1) {
throw new InvalidPathException(targetName, "Component name must contain tag and name, e.g. div-test");
}
componentTag = targetName.substring(0, pos);
componentName = targetName.substring(pos + 1);
if (componentName.isEmpty() || componentTag.isEmpty()) {
throw new InvalidPathException(targetName, "Component name must contain tag and name, e.g. div-test");
}
final App app = StructrApp.getInstance(fs.getSecurityContext());
try (final Tx tx = app.tx()) {
final ShadowDocument doc = StructrApp.getInstance(fs.getSecurityContext()).nodeQuery(ShadowDocument.class).includeDeletedAndHidden().getFirst();
for (final DOMNode child : doc.getProperty(Page.elements)) {
if (!child.hasIncomingRelationships(DOMChildren.class)) {
if (componentName.equals(child.getName()) && componentTag.equals(child.getProperty(DOMElement.tag))) {
throw new FileAlreadyExistsException(targetName);
}
}
}
domNode.setProperty(DOMElement.name, componentName);
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
}
}
}
}Example 22
| Project: test-fs-master File: TestFileSystemProvider.java View source code |
/** {@inheritDoc} */
@Override
public void move(Path source, Path target, CopyOption... options) throws IOException {
source = ((TestPath) source).unwrap();
target = ((TestPath) target).unwrap();
checkIfRemoved(source);
Path sourceParent = source.getParent();
if (sourceParent != null) {
checkIfRemoved(sourceParent);
checkPermissions(sourceParent, true, AccessMode.WRITE);
}
Path targetParent = target.getParent();
if (targetParent != null) {
checkIfRemoved(targetParent);
checkPermissions(targetParent, true, AccessMode.WRITE);
}
provider.move(source, target, options);
}Example 23
| Project: fscrawler-master File: FsCrawlerUtil.java View source code |
/**
* Copy files from a source to a target
* under a _default sub directory.
* @param source The source dir
* @param target The target dir
* @param options Potential options
* @throws IOException If copying does not work
*/
public static void copyDirs(Path source, Path target, CopyOption... options) throws IOException {
if (Files.notExists(target)) {
Files.createDirectory(target);
}
logger.debug(" --> Copying resources from [{}]", source);
if (Files.notExists(source)) {
throw new RuntimeException(source + " doesn't seem to exist.");
}
Files.walkFileTree(source, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new InternalFileVisitor(source, target, options));
logger.debug(" --> Resources ready in [{}]", target);
}Example 24
| Project: openjdk-master File: UnixCopyFile.java View source code |
static Flags fromCopyOptions(CopyOption... options) { Flags flags = new Flags(); flags.followLinks = true; for (CopyOption option : options) { if (option == StandardCopyOption.REPLACE_EXISTING) { flags.replaceExisting = true; continue; } if (option == LinkOption.NOFOLLOW_LINKS) { flags.followLinks = false; continue; } if (option == StandardCopyOption.COPY_ATTRIBUTES) { // copy all attributes but only fail if basic attributes // cannot be copied flags.copyBasicAttributes = true; flags.copyPosixAttributes = true; flags.copyNonPosixAttributes = true; flags.failIfUnableToCopyBasic = true; continue; } if (ExtendedOptions.INTERRUPTIBLE.matches(option)) { flags.interruptible = true; continue; } if (option == null) throw new NullPointerException(); throw new UnsupportedOperationException("Unsupported copy option"); } return flags; }
Example 25
| Project: wildfly-core-master File: PathUtil.java View source code |
/**
* Copy a path recursively.
* @param source a Path pointing to a file or a directory that must exist
* @param target a Path pointing to a directory where the contents will be copied.
* @param overwrite overwrite existing files - if set to false fails if the target file already exists.
* @throws IOException
*/
public static void copyRecursively(final Path source, final Path target, boolean overwrite) throws IOException {
final CopyOption[] options;
if (overwrite) {
options = new CopyOption[] { StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING };
} else {
options = new CopyOption[] { StandardCopyOption.COPY_ATTRIBUTES };
}
Files.walkFileTree(source, new FileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
Files.copy(dir, target.resolve(source.relativize(dir)), options);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.copy(file, target.resolve(source.relativize(file)), options);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
DeploymentRepositoryLogger.ROOT_LOGGER.cannotCopyFile(exc, file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
return FileVisitResult.CONTINUE;
}
});
}Example 26
| Project: buck-master File: FakeProjectFilesystem.java View source code |
@Override
public void move(Path source, Path target, CopyOption... options) throws IOException {
fileContents.put(MorePaths.normalize(target), fileContents.remove(MorePaths.normalize(source)));
fileAttributes.put(MorePaths.normalize(target), fileAttributes.remove(MorePaths.normalize(source)));
fileLastModifiedTimes.put(MorePaths.normalize(target), fileLastModifiedTimes.remove(MorePaths.normalize(source)));
}Example 27
| Project: Java_gui_4_ECF-master File: ECFLab.java View source code |
/**
* Copies log file created during last experiment to the destination path.
*/
protected void saveLog() {
ParametersSelection ps = (ParametersSelection) tabbedPane.getSelectedComponent();
boolean b = ps.wasRunBefore();
if (!b) {
JOptionPane.showMessageDialog(this, "This experiment was never run before!", "Action unavailable", JOptionPane.INFORMATION_MESSAGE);
return;
}
JFileChooser fc = new JFileChooser();
int retVal = fc.showSaveDialog(this);
if (retVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
Path source = Paths.get(ps.getLastLogFilePath());
Path target = Paths.get(file.getAbsolutePath());
CopyOption options = StandardCopyOption.REPLACE_EXISTING;
try {
Files.copy(source, target, options);
} catch (IOException e) {
e.printStackTrace();
}
JOptionPane.showMessageDialog(this, "Log file copied successfully!", "Saved successfully", JOptionPane.INFORMATION_MESSAGE);
}
}Example 28
| Project: jdk7-dxfs-master File: DxFileSystemProvider.java View source code |
/**
* Implements the *copy* operation using the DnaNexus API *clone*
*
*
* <p>
* See clone https://wiki.dnanexus.com/API-Specification-v1.0.0/Cloning#API-method%3A-%2Fclass-xxxx%2Fclone
*
* @param source
* @param target
* @param options
* @throws IOException
*/
@Override
public void copy(Path source, Path target, CopyOption... options) throws IOException {
List<CopyOption> opts = Arrays.asList(options);
boolean targetExists = Files.exists(target);
if (targetExists) {
if (Files.isRegularFile(target)) {
if (opts.contains(StandardCopyOption.REPLACE_EXISTING)) {
Files.delete(target);
} else {
throw new FileAlreadyExistsException("Copy failed -- target file already exists: " + target);
}
} else if (Files.isDirectory(target)) {
target = target.resolve(source.getFileName());
} else {
throw new UnsupportedOperationException();
}
}
String name1 = source.getFileName().toString();
String name2 = target.getFileName().toString();
if (!name1.equals(name2)) {
throw new UnsupportedOperationException("Copy to a file with a different name is not supported: " + source.toString());
}
final DxPath dxSource = toDxPath(source);
final DxFileSystem dxFileSystem = dxSource.getFileSystem();
dxFileSystem.fileCopy(dxSource, toDxPath(target));
}Example 29
| Project: nifi-master File: FetchFile.java View source code |
//
// The following set of methods exist purely for testing purposes
//
protected void move(final File source, final File target, final boolean overwrite) throws IOException {
final File targetDirectory = target.getParentFile();
// convert to path and use Files.move instead of file.renameTo so that if we fail, we know why
final Path targetPath = target.toPath();
if (!targetDirectory.exists()) {
Files.createDirectories(targetDirectory.toPath());
}
final CopyOption[] copyOptions = overwrite ? new CopyOption[] { StandardCopyOption.REPLACE_EXISTING } : new CopyOption[] {};
Files.move(source.toPath(), targetPath, copyOptions);
}Example 30
| Project: platform_build-master File: FakeProjectFilesystem.java View source code |
@Override
public void move(Path source, Path target, CopyOption... options) throws IOException {
fileContents.put(MorePaths.normalize(target), fileContents.remove(MorePaths.normalize(source)));
fileAttributes.put(MorePaths.normalize(target), fileAttributes.remove(MorePaths.normalize(source)));
fileLastModifiedTimes.put(MorePaths.normalize(target), fileLastModifiedTimes.remove(MorePaths.normalize(source)));
}Example 31
| Project: uberfire-master File: JGitFileSystemProvider.java View source code |
@Override
public void copy(final Path source, final Path target, final CopyOption... options) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, IOException, SecurityException {
checkNotNull("source", source);
checkNotNull("target", target);
final JGitPathImpl gSource = toPathImpl(source);
final JGitPathImpl gTarget = toPathImpl(target);
final boolean isBranch = isBranch(gSource) && isBranch(gTarget);
if (options.length == 1 && options[0] instanceof MergeCopyOption) {
if (!isBranch) {
throw new IOException("Merge needs source and target as root.");
}
this.merge(gSource, gTarget);
} else if (options.length == 1 && options[0] instanceof CherryPickCopyOption) {
if (!isBranch) {
throw new IOException("Cherry pick needs source and target as root.");
}
final String[] commits = ((CherryPickCopyOption) options[0]).getCommits();
if (commits == null || commits.length == 0) {
throw new IOException("Cherry pick needs at least one commit id.");
}
cherryPick(gSource, gTarget, commits);
} else {
if (isBranch) {
copyBranch(gSource, gTarget);
return;
}
copyAsset(gSource, gTarget, options);
}
}Example 32
| Project: hadoop-release-2.6.0-master File: FileIoProvider.java View source code |
/**
* Move the src file to the target using
* {@link Files#move(Path, Path, CopyOption...)}.
*
* @param volume target volume. null if unavailable.
* @param src source path.
* @param target target path.
* @param options See {@link Files#move} for a description
* of the options.
* @throws IOException
*/
public void move(@Nullable FsVolumeSpi volume, Path src, Path target, CopyOption... options) throws IOException {
final long begin = profilingEventHook.beforeMetadataOp(volume, MOVE);
try {
faultInjectorEventHook.beforeMetadataOp(volume, MOVE);
Files.move(src, target, options);
profilingEventHook.afterMetadataOp(volume, MOVE, begin);
} catch (Exception e) {
onFailure(volume, begin);
throw e;
}
}Example 33
| Project: jgit-master File: FileUtils.java View source code |
/**
* Rename a file or folder using the passed {@link CopyOption}s. If the
* rename fails and if we are running on a filesystem where it makes sense
* to repeat a failing rename then repeat the rename operation up to 9 times
* with 100ms sleep time between two calls. Furthermore if the destination
* exists and is a directory hierarchy with only directories in it, the
* whole directory hierarchy will be deleted. If the target represents a
* non-empty directory structure, empty subdirectories within that structure
* may or may not be deleted even if the method fails. Furthermore if the
* destination exists and is a file then the file will be replaced if
* {@link StandardCopyOption#REPLACE_EXISTING} has been set. If
* {@link StandardCopyOption#ATOMIC_MOVE} has been set the rename will be
* done atomically or fail with an {@link AtomicMoveNotSupportedException}
*
* @param src
* the old file
* @param dst
* the new file
* @param options
* options to pass to
* {@link Files#move(java.nio.file.Path, java.nio.file.Path, CopyOption...)}
* @throws AtomicMoveNotSupportedException
* if file cannot be moved as an atomic file system operation
* @throws IOException
* @since 4.1
*/
public static void rename(final File src, final File dst, CopyOption... options) throws AtomicMoveNotSupportedException, IOException {
int attempts = FS.DETECTED.retryFailedLockFileCommit() ? 10 : 1;
while (--attempts >= 0) {
try {
Files.move(src.toPath(), dst.toPath(), options);
return;
} catch (AtomicMoveNotSupportedException e) {
throw e;
} catch (IOException e) {
try {
if (!dst.delete()) {
delete(dst, EMPTY_DIRECTORIES_ONLY | RECURSIVE);
}
Files.move(src.toPath(), dst.toPath(), options);
return;
} catch (IOException e2) {
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new IOException(MessageFormat.format(JGitText.get().renameFileFailed, src.getAbsolutePath(), dst.getAbsolutePath()));
}
}
throw new IOException(MessageFormat.format(JGitText.get().renameFileFailed, src.getAbsolutePath(), dst.getAbsolutePath()));
}Example 34
| Project: jsr203-hadoop-master File: HadoopFileSystem.java View source code |
void copyFile(boolean deletesrc, byte[] src, byte[] dst, CopyOption... options) throws IOException { checkWritable(); if (Arrays.equals(src, dst)) // do nothing, src and dst are the same return; beginWrite(); try { ensureOpen(); org.apache.hadoop.fs.Path eSrc_path = new HadoopPath(this, src).getRawResolvedPath(); FileStatus eSrc = this.fs.getFileStatus(eSrc_path); if (!this.fs.exists(eSrc_path)) throw new NoSuchFileException(getString(src)); if (eSrc.isDirectory()) { // specification says to create dst directory createDirectory(dst); return; } boolean hasReplace = false; boolean hasCopyAttrs = false; for (CopyOption opt : options) { if (opt == REPLACE_EXISTING) hasReplace = true; else if (opt == COPY_ATTRIBUTES) hasCopyAttrs = true; } org.apache.hadoop.fs.Path eDst_path = new HadoopPath(this, dst).getRawResolvedPath(); if (fs.exists(eDst_path)) { if (!hasReplace) throw new FileAlreadyExistsException(getString(dst)); if (!fs.delete(eDst_path, false)) { throw new AccessDeniedException("cannot delete hdfs file " + getString(dst)); } } else { //checkParents(dst); } //Simply use FileUtil.copy here. Can we use DistCp for very big files here? zongjie@novelbio.com boolean isCanDeleteSourceFile = FileUtil.copy(fs, eSrc_path, fs, eDst_path, deletesrc, fs.getConf()); if (!isCanDeleteSourceFile) { throw new AccessDeniedException("cannot delete source file " + eSrc_path.toString()); } // org.apache.hadoop.fs.Path[] srcs = new org.apache.hadoop.fs.Path[] {eSrc_path}; // this.fs.concat(eDst_path, srcs); /* Entry u = new Entry(eSrc, Entry.COPY); // copy eSrc entry u.name(dst); // change name if (eSrc.type == Entry.NEW || eSrc.type == Entry.FILECH) { u.type = eSrc.type; // make it the same type if (!deletesrc) { // if it's not "rename", just take the data if (eSrc.bytes != null) u.bytes = Arrays.copyOf(eSrc.bytes, eSrc.bytes.length); else if (eSrc.file != null) { u.file = getTempPathForEntry(null); Files.copy(eSrc.file, u.file, REPLACE_EXISTING); } } } if (!hasCopyAttrs) u.mtime = u.atime= u.ctime = System.currentTimeMillis(); update(u); if (deletesrc) updateDelete(eSrc);*/ } finally { endWrite(); } }
Example 35
| Project: mina-sshd-master File: SftpSubsystem.java View source code |
protected void doRename(int id, String oldPath, String newPath, int flags) throws IOException {
if (log.isDebugEnabled()) {
log.debug("doRename({})[id={}] SSH_FXP_RENAME (oldPath={}, newPath={}, flags=0x{})", getServerSession(), id, oldPath, newPath, Integer.toHexString(flags));
}
Collection<CopyOption> opts = Collections.emptyList();
if (flags != 0) {
opts = new ArrayList<>();
if ((flags & SftpConstants.SSH_FXP_RENAME_ATOMIC) == SftpConstants.SSH_FXP_RENAME_ATOMIC) {
opts.add(StandardCopyOption.ATOMIC_MOVE);
}
if ((flags & SftpConstants.SSH_FXP_RENAME_OVERWRITE) == SftpConstants.SSH_FXP_RENAME_OVERWRITE) {
opts.add(StandardCopyOption.REPLACE_EXISTING);
}
}
doRename(id, oldPath, newPath, opts);
}Example 36
| Project: BigSack-master File: LogToFile.java View source code |
public final Object run() throws IOException, Exception {
switch(action) {
case 0:
// SECURITY PERMISSION - MP1
return new Boolean(activeFile.exists());
case 1:
// SECURITY PERMISSION - OP5
return new Boolean(activeFile.delete());
case 2:
// SECURITY PERMISSION - MP1 and/or OP4
// dependening on the value of activePerms
boolean exists = activeFile.exists();
Object result = new RandomAccessFile(activeFile, activePerms);
return result;
case 3:
// SECURITY PERMISSION - OP4
return new Boolean(activeFile.canWrite());
case 4:
// SECURITY PERMISSION - OP4
boolean created = activeFile.mkdirs();
return new Boolean(created);
case 5:
// SECURITY PERMISSION - MP1
return activeFile.list();
case 6:
// SECURITY PERMISSION - OP4 (Have to check these codes ??)
Path FROM = Paths.get(activeFile.toURI());
Path TO = Paths.get(toFile.toURI());
//overwrite existing file, if exists
CopyOption[] options = new CopyOption[] { StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES };
Files.copy(FROM, TO, options);
return new Boolean(true);
case 7:
// SECURITY PERMISSION - OP4
if (!activeFile.exists())
return new Boolean(true);
return new Boolean(activeFile.delete());
case 8:
return toFile.list();
case 9:
TO = Paths.get(activeFile.toURI());
FROM = Paths.get(toFile.toURI());
//overwrite existing file, if exists
options = new CopyOption[] { StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES };
Files.copy(FROM, TO, options);
return new Boolean(true);
case 10:
return (new OutputStreamWriter(new FileOutputStream(activeFile), "UTF8"));
default:
return null;
}
}Example 37
| Project: dcache-master File: SrmShell.java View source code |
@Override
public Serializable call() throws IOException {
Path dst = lcwd.resolve(dest);
Path src = lcwd.resolve(source);
if (!destNormal && Files.getFileAttributeView(dst, PosixFileAttributeView.class).readAttributes().isDirectory()) {
dst = dst.resolve(src.getFileName());
}
CopyOption[] options = (noClobber) ? new CopyOption[0] : new CopyOption[] { StandardCopyOption.REPLACE_EXISTING };
try {
Files.move(src, dst, options);
} catch (FileAlreadyExistsException e) {
throw new IllegalArgumentException("File already exists: " + dst, e);
} catch (DirectoryNotEmptyException e) {
throw new IllegalArgumentException("Directory not empty: " + dst, e);
}
return null;
}Example 38
| Project: fswrap-master File: FileSystemEventAdapter.java View source code |
@Override
public void copied(Path source, Path target, CopyOption[] options) {
}Example 39
| Project: sigmah-master File: LocalFileStorageProvider.java View source code |
/**
* {@inheritDoc}
*/
@Override
public long copy(InputStream input, String fileId, CopyOption... options) throws IOException {
Path target = Paths.get(getStorageRootPath(), fileId);
return Files.copy(input, target, options);
}Example 40
| Project: vraptor4-master File: CommonsUploadedFile.java View source code |
@Override
public void writeTo(Path target, CopyOption... options) throws IOException {
requireNonNull(target, TARGET_CANNOT_BE_NULL);
writeTo(target.toFile());
}Example 41
| Project: javafs-master File: ReadOnlyFileSystemProvider.java View source code |
@Override
public void copy(Path source, Path target, CopyOption... options) throws IOException {
throw new ReadOnlyFileSystemException();
}Example 42
| Project: sft-master File: ReadOnlyRootedFileSystemProvider.java View source code |
@Override
public void move(final Path source, final Path target, final CopyOption... options) throws IOException {
throw new IOException("ReadOnly FileSystem");
}Example 43
| Project: sftpserver-master File: ReadOnlyRootedFileSystemProvider.java View source code |
@Override
public void move(final Path source, final Path target, final CopyOption... options) throws IOException {
throw new IOException("ReadOnly FileSystem");
}Example 44
| Project: com.revolsys.open-master File: FileConnectionFileSystemProvider.java View source code |
@Override
public void copy(final Path source, final Path target, final CopyOption... options) throws IOException {
final Path sourcePath = getFilePath(source);
final Path targetPath = getFilePath(target);
Files.copy(sourcePath, targetPath, options);
}Example 45
| Project: DDT-master File: FileUtil.java View source code |
/* ----------------- ----------------- */
public static void copyToDir(Path source, Path targetDir, CopyOption... options) throws IOException {
Files.copy(source, targetDir.resolve(source.getFileName()), options);
}Example 46
| Project: dstream-master File: HdfsFileSystemProvider.java View source code |
@Override
public void copy(Path source, Path target, CopyOption... options) throws IOException {
// TODO Auto-generated method stub
}Example 47
| Project: goclipse-master File: FileUtil.java View source code |
/* ----------------- ----------------- */
public static void copyToDir(Path source, Path targetDir, CopyOption... options) throws IOException {
Files.copy(source, targetDir.resolve(source.getFileName()), options);
}Example 48
| Project: lucene-solr-master File: WindowsFS.java View source code |
@Override
public void move(Path source, Path target, CopyOption... options) throws IOException {
synchronized (openFiles) {
checkDeleteAccess(source);
super.move(source, target, options);
}
}Example 49
| Project: MelnormeEclipse-master File: FileUtil.java View source code |
/* ----------------- ----------------- */
public static void copyToDir(Path source, Path targetDir, CopyOption... options) throws IOException {
Files.copy(source, targetDir.resolve(source.getFileName()), options);
}Example 50
| Project: one-time-pad-library-master File: FileUtils.java View source code |
public static void copyFile(String inputName, String outputName) throws IOException {
File input = new File(inputName);
File output = new File(outputName);
Files.copy(input.toPath(), output.toPath(), new CopyOption[0]);
}Example 51
| Project: resourcefs-master File: ResourceFileSystemProvider.java View source code |
@Override
public void copy(Path source, Path target, CopyOption... options) throws IOException {
throw readOnly();
}Example 52
| Project: RustDT-master File: FileUtil.java View source code |
/* ----------------- ----------------- */
public static void copyToDir(Path source, Path targetDir, CopyOption... options) throws IOException {
Files.copy(source, targetDir.resolve(source.getFileName()), options);
}Example 53
| Project: fabric8-master File: FabricProfileFileSystemProvider.java View source code |
@Override
public void copy(Path source, Path target, CopyOption... options) throws IOException {
throw new ReadOnlyFileSystemException();
}Example 54
| Project: liferay-portal-master File: FileSystemProviderWrapper.java View source code |
@Override
public void copy(Path sourcePath, Path targetPath, CopyOption... copyOptions) throws IOException {
_fileSystemProvider.copy(PathWrapper.unwrapPath(sourcePath), PathWrapper.unwrapPath(targetPath), copyOptions);
}Example 55
| Project: gestalt-master File: ModuleFileSystemProvider.java View source code |
@Override
public void copy(Path source, Path target, CopyOption... options) throws IOException {
throw new UnsupportedOperationException();
}Example 56
| Project: guvnor-master File: MockIOService.java View source code |
@Override
public Path copy(Path path, Path path2, CopyOption... copyOptions) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, IOException, SecurityException {
return null;
}Example 57
| Project: kie-wb-common-master File: IOServiceMock.java View source code |
@Override
public Path copy(Path path, Path path2, CopyOption... copyOptions) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, IOException, SecurityException {
return null;
}Example 58
| Project: openjdk8-jdk-master File: FaultyFileSystem.java View source code |
@Override
public void copy(Path source, Path target, CopyOption... options) throws IOException {
triggerEx(source, "copy");
Files.copy(unwrap(source), unwrap(target), options);
}Example 59
| Project: strongbox-master File: RepositoryFileSystemProvider.java View source code |
public void copy(Path source, Path target, CopyOption... options) throws IOException {
storageFileSystemProvider.copy(unwrap(source), unwrap(target), options);
}Example 60
| Project: datakernel-master File: AsyncFile.java View source code |
/**
* Moves or renames a file to a target file.
*
* @param eventloop event loop in which a file will be used
* @param executor @param source the path to the file to move
* @param target the path to the target file (may be associated with a different provider to the source path)
* @param options options specifying how the move should be done
* @param callback callback which will be called after moving
*/
public static void move(Eventloop eventloop, ExecutorService executor, final Path source, final Path target, final CopyOption[] options, CompletionCallback callback) {
eventloop.runConcurrently(executor, new RunnableWithException() {
@Override
public void runWithException() throws Exception {
Files.move(source, target, options);
}
}, callback);
}Example 61
| Project: eguan-master File: NarUtil.java View source code |
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
CopyOption[] options = new CopyOption[] { COPY_ATTRIBUTES };
try {
Path newdir = target.resolve(source.relativize(dir));
Files.copy(dir, newdir, options);
} catch (FileAlreadyExistsException x) {
}
return CONTINUE;
}