Package io.roastedroot.zerofs
Class FileFactory
- java.lang.Object
-
- io.roastedroot.zerofs.FileFactory
-
final class FileFactory extends java.lang.ObjectFactory for creating new files and copying files. One piece of the file store implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classFileFactory.DirectorySupplierprivate classFileFactory.RegularFileSupplierprivate classFileFactory.SymbolicLinkSupplier
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Supplier<Directory>directorySupplierprivate HeapDiskdiskprivate FileTimeSourcefileTimeSourceprivate java.util.concurrent.atomic.AtomicIntegeridGeneratorprivate java.util.function.Supplier<RegularFile>regularFileSupplier
-
Constructor Summary
Constructors Constructor Description FileFactory(HeapDisk disk, FileTimeSource fileTimeSource)Creates a new file factory using the given disk for regular files and the given time source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FilecopyWithoutContent(File file)Creates and returns a copy of the given file.DirectorycreateDirectory()Creates a new directory.(package private) RegularFilecreateRegularFile()Creates a new regular file.DirectorycreateRootDirectory(Name name)Creates a new root directory with the given name.(package private) SymbolicLinkcreateSymbolicLink(ZeroFsPath target)Creates a new symbolic link referencing the given target path.java.util.function.Supplier<Directory>directoryCreator()Returns a supplier that creates directories.private intnextFileId()java.util.function.Supplier<RegularFile>regularFileCreator()Returns a supplier that creates regular files.java.util.function.Supplier<SymbolicLink>symbolicLinkCreator(ZeroFsPath target)Returns a supplier that creates a symbolic links to the given path.
-
-
-
Field Detail
-
idGenerator
private final java.util.concurrent.atomic.AtomicInteger idGenerator
-
disk
private final HeapDisk disk
-
fileTimeSource
private final FileTimeSource fileTimeSource
-
directorySupplier
private final java.util.function.Supplier<Directory> directorySupplier
-
regularFileSupplier
private final java.util.function.Supplier<RegularFile> regularFileSupplier
-
-
Constructor Detail
-
FileFactory
public FileFactory(HeapDisk disk, FileTimeSource fileTimeSource)
Creates a new file factory using the given disk for regular files and the given time source.
-
-
Method Detail
-
nextFileId
private int nextFileId()
-
createDirectory
public Directory createDirectory()
Creates a new directory.
-
createRootDirectory
public Directory createRootDirectory(Name name)
Creates a new root directory with the given name.
-
createRegularFile
RegularFile createRegularFile()
Creates a new regular file.
-
createSymbolicLink
SymbolicLink createSymbolicLink(ZeroFsPath target)
Creates a new symbolic link referencing the given target path.
-
copyWithoutContent
public File copyWithoutContent(File file) throws java.io.IOException
Creates and returns a copy of the given file.- Throws:
java.io.IOException
-
directoryCreator
public java.util.function.Supplier<Directory> directoryCreator()
Returns a supplier that creates directories.
-
regularFileCreator
public java.util.function.Supplier<RegularFile> regularFileCreator()
Returns a supplier that creates regular files.
-
symbolicLinkCreator
public java.util.function.Supplier<SymbolicLink> symbolicLinkCreator(ZeroFsPath target)
Returns a supplier that creates a symbolic links to the given path.
-
-