/** * Creates a new directory at the given path. The given attributes will be set on the new file if * possible. */ public Directory createDirectory(JimfsPath path, FileAttribute<?>... attrs) throws IOException { return (Directory) createFile(path, store.directoryCreator(), true, attrs); }
/** * Creates a new symbolic link at the given path with the given target. The given attributes will * be set on the new file if possible. */ public SymbolicLink createSymbolicLink( JimfsPath path, JimfsPath target, FileAttribute<?>... attrs) throws IOException { if (!store.supportsFeature(Feature.SYMBOLIC_LINKS)) { throw new UnsupportedOperationException(); } return (SymbolicLink) createFile(path, store.symbolicLinkCreator(target), true, attrs); }
/** * Gets or creates a new regular file with a write lock (assuming the file does not exist). */ private RegularFile getOrCreateRegularFileWithWriteLock( JimfsPath path, Set<OpenOption> options, FileAttribute<?>[] attrs) throws IOException { store.writeLock().lock(); try { File file = createFile(path, store.regularFileCreator(), options.contains(CREATE_NEW), attrs); // the file already existed but was not a regular file if (!file.isRegularFile()) { throw new FileSystemException(path.toString(), null, "not a regular file"); } return open((RegularFile) file, options); } finally { store.writeLock().unlock(); } }
/** * Creates a new directory at the given path. The given attributes will be set on the new file if * possible. */ public Directory createDirectory(JimfsPath path, FileAttribute<?>... attrs) throws IOException { return (Directory) createFile(path, store.directoryCreator(), true, attrs); }
/** * Creates a new symbolic link at the given path with the given target. The given attributes will * be set on the new file if possible. */ public SymbolicLink createSymbolicLink( JimfsPath path, JimfsPath target, FileAttribute<?>... attrs) throws IOException { if (!store.supportsFeature(Feature.SYMBOLIC_LINKS)) { throw new UnsupportedOperationException(); } return (SymbolicLink) createFile(path, store.symbolicLinkCreator(target), true, attrs); }
/** * Gets or creates a new regular file with a write lock (assuming the file does not exist). */ private RegularFile getOrCreateRegularFileWithWriteLock( JimfsPath path, Set<OpenOption> options, FileAttribute<?>[] attrs) throws IOException { store.writeLock().lock(); try { File file = createFile(path, store.regularFileCreator(), options.contains(CREATE_NEW), attrs); // the file already existed but was not a regular file if (!file.isRegularFile()) { throw new FileSystemException(path.toString(), null, "not a regular file"); } return open((RegularFile) file, options); } finally { store.writeLock().unlock(); } }