de.matrixweb.vfs.VFS.stack()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中de.matrixweb.vfs.VFS.stack()方法的一些代码示例,展示了VFS.stack()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。VFS.stack()方法的具体详情如下:
包路径:de.matrixweb.vfs.VFS
类名称:VFS
方法名:stack

VFS.stack介绍

[英]Stacks a new VFS root on-top of the current one. The result is a new virtual file-system backed by the old one. The old one is read-only afterwards.
Note: All current references to VFiles must be considered outdated!
[中]在当前VFS根上堆叠一个新的VFS根。结果是一个新的虚拟文件系统得到了旧文件系统的支持。旧的是只读的。
注意:所有当前对VFiles的引用都必须被认为是过时的!

代码示例

代码示例来源:origin: de.matrixweb.smaller/merge

private Resource executeComplexMerge(final VFS vfs, final Resource resource,
  final Map<String, Object> options) throws IOException {
 final Object typeOption = options.get("type");
 if (!(resource instanceof ResourceGroup) || typeOption != null
   && resource.getType() != Type.valueOf(typeOption.toString())) {
  return resource;
 }
 final ResourceGroup group = (ResourceGroup) resource;
 final Resource input = group.getResources().get(0);
 final VFile snapshot = vfs.stack();
 try {
  final VFile target = vfs.find(input.getPath());
  final Writer writer = VFSUtils.createWriter(target);
  try {
   writer.write(group.getMerger().merge(group.getResources()));
  } finally {
   IOUtils.closeQuietly(writer);
  }
  return input.getResolver().resolve(target.getPath());
 } catch (final IOException e) {
  vfs.rollback(snapshot);
  throw e;
 }
}

代码示例来源:origin: de.matrixweb.smaller/resource

final String resultType, final ProcessorCallback callback)
 throws IOException {
final VFile snapshot = vfs.stack();
try {

代码示例来源:origin: de.matrixweb.smaller/resource

final String sourceType, final String resultType,
 final ProcessorCallback callback) throws IOException {
final VFile snapshot = vfs.stack();
try {
 final VFile source = vfs.find(input.getPath());

代码示例来源:origin: de.matrixweb.smaller/merge

/**
 * @see de.matrixweb.smaller.resource.Processor#execute(de.matrixweb.vfs.VFS,
 *      de.matrixweb.smaller.resource.Resource, java.util.Map)
 */
@Override
public Resource execute(final VFS vfs, final Resource resource,
  final Map<String, Object> options) throws IOException {
 // Version 1.0.0 handling
 if (getVersion(options).isAtLeast(Version._1_0_0)) {
  try {
   if (!(resource instanceof ResourceGroup) && resource != null
     && FilenameUtils.isExtension(resource.getPath(), "json")) {
    return executeSimpleMerge(vfs, resource, options);
   }
   return executeComplexMerge(vfs, resource, options);
  } catch (final IOException e) {
   throw new SmallerException("Failed to merge files", e);
  }
 }
 final VFile snapshot = vfs.stack();
 try {
  final VFile file = vfs.find(resource.getPath());
  VFSUtils.write(file, resource.getContents());
  return resource.getResolver().resolve(file.getPath());
 } catch (final IOException e) {
  vfs.rollback(snapshot);
  throw e;
 }
}

相关文章