copyAttributes(source, dest); } finally { if (bufIn != null) {
/** Copies this file. This allows the filesystem to perform any additional * operation associated with the copy. But the default implementation is simple * copy of the file and its attributes * * @param target target folder to move this file to * @param name new basename of file * @param ext new extension of file (ignored for folders) * @return the newly created file object representing the moved file */ public FileObject copy(FileObject target, String name, String ext) throws IOException { if (isFolder()) { if (FileUtil.isParentOf(this, target)) { throw new FSException(NbBundle.getMessage(FileObject.class, "EXC_OperateChild", this, target)); // NOI18N } FileObject peer = target.createFolder(name); FileUtil.copyAttributes(this, peer); for (FileObject fo : getChildren()) { fo.copy(peer, fo.getName(), fo.getExt()); } return peer; } FileObject dest = FileUtil.copyFileImpl(this, target, name, ext); return dest; }
private static void setTemplateAttributes(FileObject fo, FileObject from) throws IOException { FileUtil.copyAttributes(from, fo); fo.setAttribute(TEMPLATE_LOCALIZING_BUNDLE_ATTRIBUTE, null); }
FileUtil.copyAttributes (getFile (), fo);
/** Creates new folder and copies attributes. * @param f the folder to create this entry in * @param suffix suffix appended to the new name to use * @return the copied <code>FileObject</code> or <code>null</code> if it cannot be copied * @exception IOException when the operation fails */ public FileObject copy (FileObject f, String suffix) throws IOException { String add = suffix + ((getFile ().getExt ().length () > 0) ? "." + getFile ().getExt () : ""); FileObject fo = FileUtil.createFolder (f, getFile ().getName () + add); FileUtil.copyAttributes (getFile (), fo); return fo; }
FileUtil.copyAttributes(getFile(), fo);
FileUtil.copyAttributes(getFile(), fo);
/** Restore entries from the list. If Entry.getFile () has changed from * time when backup list was created, original file is restored and * Entry is re-assigned to it. * @param backup list obtained from {@link #saveEntries ()} function */ final void restoreEntries(List backup) { Iterator it = backup.iterator (); while (it.hasNext ()) { Pair p = (Pair)it.next (); if (p.entry.getFile ().equals (p.file)) continue; if (p.file.isValid()) { p.entry.changeFile (p.file); } else { // copy back try { if (p.entry.getFile ().isData ()) p.entry.changeFile (p.entry.getFile ().copy (p.file.getParent (), p.file.getName (), p.file.getExt ())); else { FileObject fo = p.file.getParent ().createFolder (p.file.getName ()); FileUtil.copyAttributes (p.entry.getFile (), fo); p.entry.changeFile (fo); } } catch (IOException e) { // should not occure } } } }
/** Creates new folder and copies attributes, the template flag is cleared. * @param f the folder to create this entry in * @param name the new name to use * @return the copied <code>FileObject</code> or <code>null</code> if it cannot be copied * @exception IOException when the operation fails */ public FileObject createFromTemplate (FileObject f, String name) throws IOException { if (name == null) { name = FileUtil.findFreeFileName( f, getFile ().getName (), getFile ().getExt () ); } FileObject fo = FileUtil.createFolder (f, name); FileUtil.copyAttributes (getFile (), fo); DataObject.setTemplate (fo, false); return fo; }