@Override public void setLength(final long newLength) throws IOException { this.file.resize(newLength); this.buf = this.file.getData().getContent(); } }
@Override public void setLength(final long newLength) throws IOException { this.file.resize(newLength); this.buf = this.file.getData().getContent(); } }
@Override public void setLength(final long newLength) throws IOException { this.file.resize(newLength); this.buf = this.file.getData().getContent(); } }
@Override public void setLength(final long newLength) throws IOException { this.file.resize(newLength); this.buf = this.file.getData().getContent(); } }
/** * @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); }
/** * @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); }
/** * @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); }
/** * @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); }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { final RamFileData data = this.file.getData(); final int size = data.size(); final int newSize = size + len; // Store the Exception in order to notify the client again on close() try { this.file.resize(newSize); } catch (final IOException e) { this.exception = e; throw e; } System.arraycopy(b, off, data.getContent(), size, len); }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { final RamFileData data = this.file.getData(); final int size = data.size(); final int newSize = size + len; // Store the Exception in order to notify the client again on close() try { this.file.resize(newSize); } catch (final IOException e) { this.exception = e; throw e; } System.arraycopy(b, off, data.getContent(), size, len); }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { final RamFileData data = this.file.getData(); final int size = data.size(); final int newSize = size + len; // Store the Exception in order to notify the client again on close() try { this.file.resize(newSize); } catch (final IOException e) { this.exception = e; throw e; } System.arraycopy(b, off, data.getContent(), size, len); }
/** * Saves a file * * @param file * @throws FileSystemException */ void save(final RamFileObject file) throws FileSystemException { // Validate name if (file.getData().getName() == null) { throw new FileSystemException(new IllegalStateException("The data has no name. " + file)); } // Add to the parent if (file.getName().getDepth() > 0) { final RamFileData parentData = this.cache.get(file.getParent().getName()); // Only if not already added if (!parentData.hasChildren(file.getData())) { final RamFileObject parent = (RamFileObject) file.getParent(); parent.getData().addChild(file.getData()); parent.close(); } } // Store in cache cache.put(file.getName(), file.getData()); file.getData().updateLastModified(); file.close(); }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { final RamFileData data = this.file.getData(); final int size = data.size(); final int newSize = size + len; // Store the Exception in order to notify the client again on close() try { this.file.resize(newSize); } catch (final IOException e) { this.exception = e; throw e; } System.arraycopy(b, off, data.getContent(), size, len); }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (this.getLeftBytes() < len) { final int newSize = this.buf.length + len - this.getLeftBytes(); this.file.resize(newSize); this.buf = this.file.getData().getContent(); } System.arraycopy(b, off, this.buf, filePointer, len); this.filePointer += len; }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (this.getLeftBytes() < len) { final int newSize = this.buf.length + len - this.getLeftBytes(); this.file.resize(newSize); this.buf = this.file.getData().getContent(); } System.arraycopy(b, off, this.buf, filePointer, len); this.filePointer += len; }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (this.getLeftBytes() < len) { final int newSize = this.buf.length + len - this.getLeftBytes(); this.file.resize(newSize); this.buf = this.file.getData().getContent(); } System.arraycopy(b, off, this.buf, filePointer, len); this.filePointer += len; }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (this.getLeftBytes() < len) { final int newSize = this.buf.length + len - this.getLeftBytes(); this.file.resize(newSize); this.buf = this.file.getData().getContent(); } System.arraycopy(b, off, this.buf, filePointer, len); this.filePointer += len; }
/** * 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(); }
/** * 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(); }
/** * 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(); }