@Override public Long getContentLength() { return file.getSize(); }
private void append(VirtualFile f, String padding) { String baseName = f.getName(); String size = formatBytes(f.getSize()); buf.append(String.format(fmt, padding, "+-- ", size, baseName)); buf.append("\n"); }
/** * @return * @throws IOException */ public InputStream limit(VirtualFile resource) throws IOException { InputStream is = resource.openStream(); long resourceSize = resource.getSize(); // if we're limiting and know we're not going to consume the whole file, we skip // ahead so that we get the tail of the file instead of the beginning of it, and we // toggle the done switch. if(limit != -1){ long leftToRead = limit - amountRead; if(leftToRead < resourceSize){ Utils.skip(is, resourceSize - leftToRead); done = true; } else { amountRead += resourceSize; } } return is; }
/** * Copies resources from WAR to target folder. * * @param virtualFileOrFolder * @param targetFolder * @throws IOException */ static void copyFromWarToFolder(VirtualFile virtualFileOrFolder, File targetFolder) throws IOException { if (virtualFileOrFolder.isDirectory() && !virtualFileOrFolder.getName().contains(".")) { if (targetFolder.getName().equalsIgnoreCase(virtualFileOrFolder.getName())) { for (VirtualFile innerFileOrFolder : virtualFileOrFolder.getChildren()) { copyFromWarToFolder(innerFileOrFolder, targetFolder); } } else { File innerTargetFolder = new File(targetFolder, virtualFileOrFolder.getName()); innerTargetFolder.mkdir(); for (VirtualFile innerFileOrFolder : virtualFileOrFolder.getChildren()) { copyFromWarToFolder(innerFileOrFolder, innerTargetFolder); } } } else { File targetFile = new File(targetFolder, virtualFileOrFolder.getName()); if (!targetFile.exists() || targetFile.length() != virtualFileOrFolder.getSize()) { FileUtils.copyURLToFile(virtualFileOrFolder.asFileURL(), targetFile); } } } }
public int getContentLength() { final long size = file.getSize(); return size > (long) Integer.MAX_VALUE ? -1 : (int) size; }
/** * {@inheritDoc} * */ @Override public long getSize() { return virtualFile.getSize(); }
@Override public long getSize() { return file.getSize(); } @Override
@Override public long getSize() { return file.getSize(); } @Override
public long getSize() { final long size = entry.getSize(); return size == -1 ? 0 : size; } }
public long getSize() { final long size = entry.getSize(); return size == -1 ? 0 : size; } }
public long getSize() { final long size = entry.getSize(); return size == -1 ? 0 : size; } }
@Override public long getSize() { return file.getSize(); } @Override
public long getSize() { final long size = entry.getSize(); return size == -1 ? 0 : size; } }
public long getSize() { final long size = entry.getSize(); return size == -1 ? 0 : size; } }
@Override public Long getContentLength() { return file.getSize(); }
@Override public Long getContentLength() { return file.getSize(); }
@Override public long getSize() { return file.getSize(); }
public long getSize() { return file.getSize(); }
/** * {@inheritDoc} */ public long getSize(VirtualFile mountPoint, VirtualFile target) { final VirtualFile assemblyFile = assembly.getFile(mountPoint, target); return assemblyFile == null ? 0L : assemblyFile.getSize(); }
public Attributes getAttributes(Name name, String[] attrIds) throws NamingException { VirtualFile entry = null; if (name.isEmpty()) { entry = base; } else { entry = treeLookup(name); } if (entry == null) throw new NamingException(sm.getString("resources.notFound", name)); ResourceAttributes attrs = new ResourceAttributes(); attrs.setCreationDate(new Date(entry.getLastModified())); attrs.setName(entry.getName()); if (entry.isFile()) attrs.setResourceType(""); attrs.setContentLength(entry.getSize()); attrs.setLastModified(entry.getLastModified()); return attrs; }