/* * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package java.nio.file; import java.nio.file.attribute.*; import java.io.InputStream; import java.io.IOException; /** * Helper class to support copying or moving files when the source and target * are associated with different providers. */ class CopyMoveHelper { private CopyMoveHelper() { } /** * Parses the arguments for a file copy operation. */ private static class CopyOptions { boolean replaceExisting = false; boolean copyAttributes = false; boolean followLinks = true; private CopyOptions() { } static CopyOptions parse(CopyOption... options) { CopyOptions result = new CopyOptions(); for (CopyOption option: options) { if (option == StandardCopyOption.REPLACE_EXISTING) { result.replaceExisting = true; continue; } if (option == LinkOption.NOFOLLOW_LINKS) { result.followLinks = false; continue; } if (option == StandardCopyOption.COPY_ATTRIBUTES) { result.copyAttributes = true; continue; } if (option == null) throw new NullPointerException(); throw new UnsupportedOperationException("'" + option + "' is not a recognized copy option"); } return result; } } /** * Converts the given array of options for moving a file to options suitable * for copying the file when a move is implemented as copy + delete. */ private static CopyOption[] convertMoveToCopyOptions(CopyOption... options) throws AtomicMoveNotSupportedException { int len = options.length; CopyOption[] newOptions = new CopyOption[len+2]; for (int i=0; i