/** Copies file to the selected folder. * This implementation simply copies the file by stream content. * Uses the extension of the source file. * @param source source file object * @param destFolder destination folder * @param newName file name (without extension) of destination file * @return the created file object in the destination folder * @exception IOException if <code>destFolder</code> is not a folder or does not exist; the destination file already exists; or * another critical error occurs during copying */ public static FileObject copyFile(FileObject source, FileObject destFolder, String newName) throws IOException { return copyFile(source, destFolder, newName, source.getExt()); }
/** Copies content of one folder into another. * @param source source folder * @param target target folder * @exception IOException if it fails */ private static void copyContent(FileObject source, FileObject target) throws IOException { FileObject[] srcArr = source.getChildren(); copyAttrs(source, target); //added for (int i = 0; i < srcArr.length; i++) { FileObject child = srcArr[i]; if (MultiFileSystem.isMaskFile(child)) { continue; } if (target.getFileObject(child.getName(), child.getExt()) == null) { if (child.isData()) { FileObject fo = FileUtil.copyFile(child, target, child.getName(), child.getExt()); if (fo != null) { copyAttrs(child, fo); } } else { FileObject targetChild = target.createFolder(child.getName()); copyContent(child, targetChild); } } } }
@Override public void copyTo (final @Nonnull ResourceFile targetFolder) throws IOException { FileUtil.copyFile(delegate, ((ResourceFileNetBeansPlatform)targetFolder).delegate, delegate.getName()); }
/** Copies file to the selected folder. * This implementation simply copies the file by stream content. * Uses the extension of the source file. * @param source source file object * @param destFolder destination folder * @param newName file name (without extension) of destination file * @return the created file object in the destination folder * @exception IOException if <code>destFolder</code> is not a folder or does not exist; the destination file already exists; or * another critical error occurs during copying */ public static FileObject copyFile(FileObject source, FileObject destFolder, String newName) throws IOException { return copyFile(source, destFolder, newName, source.getExt()); }
/** Copies file to the selected folder. * This implementation simply copies the file by stream content. * Uses the extension of the source file. * @param source source file object * @param destFolder destination folder * @param newName file name (without extension) of destination file * @return the created file object in the destination folder * @exception IOException if <code>destFolder</code> is not a folder or does not exist; the destination file already exists; or * another critical error occurs during copying */ public static FileObject copyFile(FileObject source, FileObject destFolder, String newName) throws IOException { return copyFile(source, destFolder, newName, source.getExt()); }
/** * Copy queue to sensor project dir. * * @param copyQueue List of files to copy to the archive dir. * @Param destination FileObject to copy the files to. * @throws IOException */ protected void copy(List<FileObject> copyQueue, FileObject destination) throws IOException { for (FileObject file : copyQueue) { try { FileUtil.copyFile(file, destination, file.getName()); } catch (SyncFailedException ex) { //Do nothing file already exists } } copyQueue.clear(); }
/** * Copy queue to sensor project dir. * * @param copyQueue List of files to copy to the archive dir. * @Param destination FileObject to copy the files to. * @throws IOException * @deprecated Move to Util */ @Deprecated public static void copy(List<FileObject> copyQueue, FileObject destination) throws IOException { for (FileObject file : copyQueue) { try { org.openide.filesystems.FileUtil.copyFile(file, destination, file.getName()); } catch (SyncFailedException ex) { //Do nothing file already exists } } copyQueue.clear(); }
/** * Copy queue to specified dir. * * @param copyQueue List of files to copy to the specified destination dir. * @Param destination FileObject to copy the files to. * @throws IOException */ public static void copy(Set<FileObject> copyQueue, FileObject destination) throws IOException { for (FileObject file : copyQueue) { try { org.openide.filesystems.FileUtil.copyFile(file, destination, file.getName()); } catch (SyncFailedException ex) { //Do nothing file already exists } } copyQueue.clear(); } }
private void exportSnapshot(FileObject selectedSnapshot, FileObject targetFolder, String fileName, String fileExt) { if (checkFileExists(new SelectedFile(targetFolder, fileName, fileExt))) { try { FileUtil.copyFile(selectedSnapshot, targetFolder, fileName, fileExt); } catch (IOException e) { LOGGER.log(Level.SEVERE, Bundle.ResultsManager_SnapshotExportFailedMsg(e.getMessage()), e); } } }
/** * Copy sourcefiles to import-folder * @param dataObject */ @Override public void importSources(DataObject dataObject) { FileObject importFolder = getImportFolder(true); Iterator<FileObject> files = dataObject.files().iterator(); while(files.hasNext()){ FileObject current = files.next(); try { String newFileName = FileUtil.findFreeFileName(importFolder, current.getName(), current.getExt()); FileUtil.copyFile(current, importFolder, newFileName); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } }
/** * Copies the specified fileObject to the specified targetFolder. Tries to * get a free filename for the file object * * @param targetFolder the folder the fileObject must be copied to * @param toCopy the file to be copied * @return the copied fileObject or null if it could not be copied */ private FileObject copy(FileObject targetFolder, FileObject toCopy) { try { String newFileName = FileUtil.findFreeFileName(targetFolder, toCopy.getName(), toCopy.getExt()); return FileUtil.copyFile(toCopy, targetFolder, newFileName); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Could not copy file {0} with the exception {1}", new Object[]{toCopy.getName(), ex}); } return null; }
private boolean doCopy(FileObject source, File target) throws IOException { LOGGER.log(Level.FINE, "Copying file {0} -> {1}", new Object[] {getPath(source), target}); File targetParent = target.getParentFile(); if (source.isData()) { doDelete(target); FileObject parent = FileUtil.createFolder(targetParent); FileUtil.copyFile(source, parent, source.getName(), source.getExt()); LOGGER.log(Level.FINE, "File {0} copied to {1}", new Object[] {getPath(source), target}); } else { String[] childs = target.list(); if (childs == null || childs.length == 0) { doDelete(target); } FileUtil.createFolder(target); LOGGER.log(Level.FINE, "Folder {0} created", target); } return target.exists(); }
/** * Copies the specified FileObject to the specified targetFolder. * * <p> * Tries to get a free filename for the file object</p> * * @param targetFolder the folder the fileObject must be copied to * @param toCopy the file to be copied * @return the copied fileObject or null if it could not be copied */ private FileObject copy(FileObject targetFolder, FileObject toCopy) { try { String newFileName = FileUtil.findFreeFileName(targetFolder, toCopy.getName(), toCopy.getExt()); return FileUtil.copyFile(toCopy, targetFolder, newFileName); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Could not copy file {0} with the exception {1}", new Object[]{toCopy.getName(), ex}); } return null; }
static void copyTemplate(Project proj) throws IOException { FileObject projDir = proj.getProjectDirectory(); FileObject jnlpBuildFile = projDir.getFileObject("nbproject/extendArchiveGF.xml"); // NOI18N if (jnlpBuildFile == null) { FileObject templateFO = FileUtil.getConfigFile("Templates/SunResources/extendArchiveGF.xml"); // NOI18N if (templateFO != null) { FileUtil.copyFile(templateFO, projDir.getFileObject("nbproject"), "extendArchiveGF"); // NOI18N } } }
private FileObject copy(FileObject source) throws IOException { FileObject fo = p.getProjectDirectory(); //target/nb-private/tesng-suite.xml FileObject folder = FileUtil.createFolder(fo, "target/nb-private"); //NOI18N FileObject cfg = folder.getFileObject("testng-suite", "xml"); //NOI18N if (cfg != null) { cfg.delete(); } return FileUtil.copyFile(source, folder, "testng-suite"); //NOI18N }
@Messages({"# {0} - file location", "FileChooserAccessory_no_such_file=Cannot copy nonexistent path {0} to libraries folder."}) private void copyFiles(List<File> files, FileObject newRoot) throws IOException { List<File> fs = new ArrayList<File>(); for (File file : files) { FileObject fo = FileUtil.toFileObject(file); if (fo == null) { throw Exceptions.attachLocalizedMessage(new FileNotFoundException(file.toString()), FileChooserAccessory_no_such_file(file)); } FileObject newFO; if (fo.isFolder()) { newFO = copyFolderRecursively(fo, newRoot); } else { FileObject foExists = newRoot.getFileObject(fo.getName(), fo.getExt()); if (foExists != null) { foExists.delete(); } newFO = FileUtil.copyFile(fo, newRoot, fo.getName(), fo.getExt()); } fs.add(FileUtil.toFile(newFO)); } copiedRelativeFiles = getRelativeFiles(fs); }
private void copyFolder(FileObject source, FileObject dest) throws IOException { assert source.isFolder() : "Source is not a folder"; // NOI18N assert dest.isFolder() : "Source is not a folder"; // NOI18N for (FileObject child : source.getChildren()) { if (child.isFolder()) { FileObject created = FileUtil.createFolder(dest, child.getNameExt()); copyFolder(child, created); } else { FileUtil.copyFile(child, dest, child.getName(), child.getExt()); } } }
private static void doCopy(Project original, FileObject from, FileObject toParent) throws IOException { if (!VisibilityQuery.getDefault().isVisible(from)) { //Do not copy invisible files/folders. return ; } if (!original.getProjectDirectory().equals(FileOwnerQuery.getOwner(from).getProjectDirectory())) { return ; } //#109580 if (SharabilityQuery.getSharability(from) == SharabilityQuery.Sharability.NOT_SHARABLE) { return; } if (from.isFolder()) { FileObject copy = toParent.createFolder(from.getNameExt()); for (FileObject kid : from.getChildren()) { doCopy(original, kid, copy); } } else { assert from.isData(); FileObject target = FileUtil.copyFile(from, toParent, from.getName(), from.getExt()); } }
/** Copies content of one folder into another. * @param source source folder * @param target target folder * @exception IOException if it fails */ private static void copyContent (FileObject source, FileObject target) throws IOException { FileObject[] srcArr = source.getChildren (); copyAttrs (source, target);//added for (int i = 0; i < srcArr.length; i++) { FileObject child = srcArr[i]; if (MultiFileSystem.isMaskFile (child) ) continue; if (target.getFileObject (child.getName (), child.getExt ()) == null) { if (child.isData ()) { FileObject fo = FileUtil.copyFile (child, target, child.getName (), child.getExt ()); if (fo != null) copyAttrs (child, fo); } else { FileObject targetChild = target.createFolder (child.getName ()); copyContent (child, targetChild); } } } }
@Override public void run() throws IOException { assert sourceFolder.isFolder() : sourceFolder; assert destination.isFolder() : destination; FileObject destinationSubFolder = destination.getFileObject(sourceFolder.getName()); if (destinationSubFolder == null) { destinationSubFolder = destination.createFolder(sourceFolder.getName()); } for (FileObject fo : sourceFolder.getChildren()) { if (fo.isFolder()) { copyFolderRecursively(fo, destinationSubFolder); } else { FileObject foExists = destinationSubFolder.getFileObject(fo.getName(), fo.getExt()); if (foExists != null) { foExists.delete(); } FileUtil.copyFile(fo, destinationSubFolder, fo.getName(), fo.getExt()); } } } });