@Override protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions) throws FileSystemException { return new RamFileSystem(name, fileSystemOptions); }
@Override protected void doAttach() throws Exception { this.getAbstractFileSystem().attach(this); }
/** * Import a Tree. * * @param file The File * @throws FileSystemException if an error occurs. */ public void importTree(final File file) throws FileSystemException { final FileObject fileFo = getFileSystemManager().toFileObject(file); this.toRamFileObject(fileFo, fileFo); }
/** * @param newSize * @throws IOException if the new size exceeds the limit */ synchronized void resize(final long newSize) throws IOException { final RamFileSystem afs = getAbstractFileSystem(); final FileSystemOptions afsOptions = afs.getFileSystemOptions(); if (afsOptions != null) { final long maxSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(afsOptions); if (afs.size() + newSize - this.size() > maxSize) { throw new IOException("FileSystem capacity (" + maxSize + ") exceeded."); } } this.data.resize(newSize); }
/** * @param from The original file. * @param to The new file. * @throws FileSystemException if an error occurs. */ void rename(final RamFileObject from, final RamFileObject to) throws FileSystemException { if (!this.cache.containsKey(from.getName())) { throw new FileSystemException("File does not exist: " + from.getName()); } // Copy data to.getData().setContent(from.getData().getContent()); to.getData().setLastModified(from.getData().getLastModified()); to.getData().setType(from.getData().getType()); this.save(to); this.delete(from); }
.resolveFile(fo.getName().getPath().substring(root.getName().getPath().length())); if (fo.getType().hasChildren()) { this.toRamFileObject(child, root);
@Override protected void doDelete() throws Exception { if (this.isContentOpen()) { throw new FileSystemException(this.getName() + " cannot be deleted while the file is openg"); } getAbstractFileSystem().delete(this); }
@Override protected void doRename(final FileObject newFile) throws Exception { final RamFileObject newRamFileObject = (RamFileObject) FileObjectUtils.getAbstractFileObject(newFile); getAbstractFileSystem().rename(this, newRamFileObject); }
@Override protected String[] doListChildren() throws Exception { return this.getAbstractFileSystem().listChildren(this.getName()); }
private void save() throws FileSystemException { this.getAbstractFileSystem().save(this); }
/** * Delete a file * * @param file * @throws FileSystemException */ void delete(final RamFileObject file) throws FileSystemException { // root is read only check if (file.getParent() == null) { throw new FileSystemException("unable to delete root"); } // Remove reference from cache this.cache.remove(file.getName()); // Notify the parent final RamFileObject parent = (RamFileObject) this.resolveFile(file.getParent().getName()); parent.getData().removeChild(file.getData()); parent.close(); // Close the file file.getData().clear(); file.close(); }
/** * @param newSize * @throws IOException if the new size exceeds the limit */ synchronized void resize(final long newSize) throws IOException { final RamFileSystem afs = getAbstractFileSystem(); final FileSystemOptions afsOptions = afs.getFileSystemOptions(); if (afsOptions != null) { final long maxSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(afsOptions); if (afs.size() + newSize - this.size() > maxSize) { throw new IOException("FileSystem capacity (" + maxSize + ") exceeded."); } } this.data.resize(newSize); }
/** * @param from The original file. * @param to The new file. * @throws FileSystemException if an error occurs. */ void rename(final RamFileObject from, final RamFileObject to) throws FileSystemException { if (!this.cache.containsKey(from.getName())) { throw new FileSystemException("File does not exist: " + from.getName()); } // Copy data to.getData().setContent(from.getData().getContent()); to.getData().setLastModified(from.getData().getLastModified()); to.getData().setType(from.getData().getType()); this.save(to); this.delete(from); }
.resolveFile(fo.getName().getPath().substring(root.getName().getPath().length())); if (fo.getType().hasChildren()) { this.toRamFileObject(child, root);
@Override protected void doDelete() throws Exception { if (this.isContentOpen()) { throw new FileSystemException(this.getName() + " cannot be deleted while the file is openg"); } getAbstractFileSystem().delete(this); }
@Override protected void doRename(final FileObject newFile) throws Exception { final RamFileObject newRamFileObject = (RamFileObject) FileObjectUtils.getAbstractFileObject(newFile); getAbstractFileSystem().rename(this, newRamFileObject); }
@Override protected String[] doListChildren() throws Exception { return this.getAbstractFileSystem().listChildren(this.getName()); }
private void save() throws FileSystemException { this.getAbstractFileSystem().save(this); }
/** * Delete a file * * @param file * @throws FileSystemException */ void delete(final RamFileObject file) throws FileSystemException { // root is read only check FileSystemException.requireNonNull(file.getParent(), "unable to delete root"); // Remove reference from cache this.cache.remove(file.getName()); // Notify the parent final RamFileObject parent = (RamFileObject) this.resolveFile(file.getParent().getName()); parent.getData().removeChild(file.getData()); parent.close(); // Close the file file.getData().clear(); file.close(); }
/** * Import a Tree. * * @param file The File * @throws FileSystemException if an error occurs. */ public void importTree(final File file) throws FileSystemException { final FileObject fileFo = getFileSystemManager().toFileObject(file); this.toRamFileObject(fileFo, fileFo); }