@Override public int size() { return getNameCount(); } };
for (int i = 0; i < Math.min(getNameCount(), otherNames.size()); i++) { if (names.get(i).equals(otherNames.get(i))) { sharedSubsequenceLength++; int extraNamesInThis = Math.max(0, getNameCount() - sharedSubsequenceLength);
/** * Returns whether or not this path is in a normalized form. It's normal if it both contains no * "." names and contains no ".." names in a location other than the start of the path. */ private boolean isNormal() { if (getNameCount() == 0 || (getNameCount() == 1 && !isAbsolute())) { return true; } boolean foundNonParentName = isAbsolute(); // if there's a root, the path doesn't start with .. boolean normal = true; for (Name name : names) { if (name.equals(Name.PARENT)) { if (foundNonParentName) { normal = false; break; } } else { if (name.equals(Name.SELF)) { normal = false; break; } foundNonParentName = true; } } return normal; }
/** * Creates the file store for the file system. */ private static JimfsFileStore createFileStore( Configuration config, PathService pathService, FileSystemState state) { AttributeService attributeService = new AttributeService(config); // TODO(cgdecker): Make disk values configurable HeapDisk disk = new HeapDisk(config); FileFactory fileFactory = new FileFactory(disk); Map<Name, Directory> roots = new HashMap<>(); // create roots for (String root : config.roots) { JimfsPath path = pathService.parsePath(root); if (!path.isAbsolute() && path.getNameCount() == 0) { throw new IllegalArgumentException("Invalid root path: " + root); } Name rootName = path.root(); Directory rootDir = fileFactory.createRootDirectory(rootName); attributeService.setInitialAttributes(rootDir); roots.put(rootName, rootDir); } return new JimfsFileStore( new FileTree(roots), fileFactory, disk, attributeService, config.supportedFeatures, state); }
@Override public int size() { return getNameCount(); } };
for (int i = 0; i < Math.min(getNameCount(), otherNames.size()); i++) { if (names.get(i).equals(otherNames.get(i))) { sharedSubsequenceLength++; int extraNamesInThis = Math.max(0, getNameCount() - sharedSubsequenceLength);
/** * Returns whether or not this path is in a normalized form. It's normal if it both contains no * "." names and contains no ".." names in a location other than the start of the path. */ private boolean isNormal() { if (getNameCount() == 0 || getNameCount() == 1 && !isAbsolute()) { return true; } boolean foundNonParentName = isAbsolute(); // if there's a root, the path doesn't start with .. boolean normal = true; for (Name name : names) { if (name.equals(Name.PARENT)) { if (foundNonParentName) { normal = false; break; } } else { if (name.equals(Name.SELF)) { normal = false; break; } foundNonParentName = true; } } return normal; }
/** * Creates the file store for the file system. */ private static JimfsFileStore createFileStore( Configuration config, PathService pathService, FileSystemState state) { AttributeService attributeService = new AttributeService(config); // TODO(cgdecker): Make disk values configurable HeapDisk disk = new HeapDisk(config); FileFactory fileFactory = new FileFactory(disk); Map<Name, Directory> roots = new HashMap<>(); // create roots for (String root : config.roots) { JimfsPath path = pathService.parsePath(root); if (!path.isAbsolute() && path.getNameCount() == 0) { throw new IllegalArgumentException("Invalid root path: " + root); } Name rootName = path.root(); Directory rootDir = fileFactory.createRootDirectory(rootName); attributeService.setInitialAttributes(rootDir); roots.put(rootName, rootDir); } return new JimfsFileStore( new FileTree(roots), fileFactory, disk, attributeService, config.supportedFeatures, state); }