@Override public FileObject copy(FileObject target, String name, String ext) throws IOException { return fileObj.copy(target, name, ext); }
@Override public FileObject copy(FileObject target, String name, String ext) throws IOException { return delegate.copy(target, name, ext); }
/** Copies file to the selected folder. * This implementation simply copies the file by stream content. * @param source source file object * @param destFolder destination folder * @param newName file name (without extension) of destination file * @param newExt 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, String newExt) throws IOException { return source.copy(destFolder, newName, newExt); }
/** 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 (FileUtil.isParentOf(this, target)) { throw new FSException(NbBundle.getMessage(FileObject.class, "EXC_CopyChild", this, target)); // NOI18N } return leader.copy(target, name, ext); }
/** Moves this file. This allows the filesystem to perform any additional * operation associated with the move. But the default implementation is encapsulated * as copy and delete. * * @param lock File must be locked before renaming. * @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 move(FileLock lock, FileObject target, String name, String ext) throws IOException { if (getParent().equals(target)) { // it is possible to do only rename rename(lock, name, ext); return this; } else { // have to do copy FileObject dest = copy(target, name, ext); delete(lock); FileObjectLkp.reassign(this, dest); return dest; } }
/** 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; }
/** Converts the file to be writable. * The file has to be locked! * * @return file object (new leader) that is writable * @exception IOException if the object cannot be writable */ private FileObject writable(boolean copyContents) throws IOException { MultiFileSystem fs = getMultiFileSystem(); FileSystem single = fs.createWritableOn(getPath()); if (single != leader.getFileSystem()) { // if writing to a file that is not on writable fs => // copy it if (leader.isFolder()) { leader = FileUtil.createFolder(root(single), getPath()); } else { FileObject folder = FileUtil.createFolder(root(single), getParent().getPath()); if (copyContents) { leader = leader.copy(folder, leader.getName(), leader.getExt()); } else { leader = folder.createData(leader.getNameExt()); } } MfLock l = ((lock == null) ? null : lock.get()); if (l != null) { // update the lock l.addLock(leader); } } return leader; }
leader = leader.copy(folder, name, ext); copyAttrs(this, leader); } else {
/** 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 { return leader.copy (target, name, ext); }
public FileObject copy(FileObject target,String name,String ext) throws IOException { return fileObj.copy(target, name, ext); }
/** 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 { return leader.copy (target, name, ext); }
/** Copies file to the selected folder. * This implementation simply copies the file by stream content. * @param source source file object * @param destFolder destination folder * @param newName file name (without extension) of destination file * @param newExt 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, String newExt) throws IOException { return source.copy (destFolder, newName, newExt); }
/** Copies file to the selected folder. * This implementation simply copies the file by stream content. * @param source source file object * @param destFolder destination folder * @param newName file name (without extension) of destination file * @param newExt 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, String newExt) throws IOException { return source.copy (destFolder, newName, newExt); }
public FileObject copy(FileObject target,String name,String ext) throws IOException { return fileObj.copy(target, name, ext); }
public FileObject copy (FileObject f, String suffix) throws IOException { FileObject fo = getFile(); String newName = fo.getName() + suffix; return fo.copy (f, newName, fo.getExt ()); }
/** Moves this file. This allows the filesystem to perform any additional * operation associated with the move. But the default implementation is encapsulated * as copy and delete. * * @param lock File must be locked before renaming. * @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 move (FileLock lock, FileObject target, String name, String ext) throws IOException { if (getParent ().equals (target)) { // it is possible to do only rename rename (lock, name, ext); return this; } else { // have to do copy FileObject dest = copy (target, name, ext); delete(lock); return dest; } }
/** Moves this file. This allows the filesystem to perform any additional * operation associated with the move. But the default implementation is encapsulated * as copy and delete. * * @param lock File must be locked before renaming. * @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 move (FileLock lock, FileObject target, String name, String ext) throws IOException { if (getParent ().equals (target)) { // it is possible to do only rename rename (lock, name, ext); return this; } else { // have to do copy FileObject dest = copy (target, name, ext); delete(lock); return dest; } }
public FileObject createFromTemplate (FileObject f, String name) throws IOException { if (name == null) { name = FileUtil.findFreeFileName( f, getFile ().getName (), getFile ().getExt () ); } FileObject fo = getFile().copy (f, name, getFile().getExt ()); // unmark template state DataObject.setTemplate (fo, false); return fo; }
/** * Copies the given file/folder into the given destination folder. * * @param src source file/folder to copy * @param dest destination folder */ private void copy(FileObject src, FileObject destFolder) throws IOException { if (src.isFolder()) { FileObject srcCopy = destFolder.getFileObject(src.getNameExt()); if (srcCopy == null) { srcCopy = destFolder.createFolder(src.getNameExt()); } FileObject [] files = src.getChildren(); for (FileObject file : files) { copy(file, srcCopy); } } else { src.copy(destFolder, src.getName(), src.getExt()); } }
/** Converts the file to be writable. * The file has to be locked! * * @return file object (new leader) that is writable * @exception IOException if the object cannot be writable */ private FileObject writable () throws IOException { MultiFileSystem fs = getMultiFileSystem (); FileSystem single = fs.createWritableOn (getPath ()); if (single != leader.getFileSystem()) { // if writing to a file that is not on writable fs => // copy it if (leader.isFolder()) { leader = FileUtil.createFolder (root (single), getPath ()); } else { FileObject folder = FileUtil.createFolder(root (single), getParent ().getPath ()); leader = leader.copy (folder, leader.getName (), leader.getExt ()); } MfLock l = (MfLock)(lock == null ? null : lock.get ()); if (l != null) { // update the lock l.addLock (leader); } } return leader; }