Class ZeroFsFileSystem
- All Implemented Interfaces:
Closeable,AutoCloseable
FileSystem implementation for ZeroFs. Most behavior for the file system is implemented by
its default file system view.
Overview of file system design
invalid reference
ZeroFsFileSystem
invalid reference
ZeroFsFileSystems
invalid reference
Configuration
Path objects that all file system operations use.
Once created, the primary entry points to the file system are
invalid reference
ZeroFsFileSystemProviderFiles, and
invalid reference
ZeroFsSecureDirectoryStream
The implementation of the methods on both of those classes is handled by the
invalid reference
FileSystemView
File system views make use of the file system's singleton
invalid reference
ZeroFsFileStore
-
handles creation of new file objects.
invalid reference
FileFactory -
handles allocation of blocks to
invalid reference
HeapDiskRegularFileinstances. -
stores the root of the file hierarchy and handles file lookup.
invalid reference
FileTree -
handles file attributes, using a set of
invalid reference
AttributeServiceimplementations to handle each supported file attribute view.invalid reference
AttributeProvider
Paths
The implementation ofPath for the file system is
invalid reference
ZeroFsPath
invalid reference
PathService
invalid reference
PathType
Paths are made up of
invalid reference
Name
- The display form is used in
PathfortoString(). It is also used for determining the equality and sort order ofPathobjects for most file systems. - The canonical form is used for equality of two
Nameobjects. This affects the notion of name equality in the file system itself for file lookup. A file system may be configured to use the canonical form of the name for path equality (a Windows-like file system configuration does this, as the real Windows file system implementation uses case-insensitive equality for its path objects.
The canonical form of a name is created by applying a series of normalizations to the original string. These normalization may be either a Unicode normalization (e.g. NFD) or case folding normalization for case-insensitivity. Normalizations may also be applied to the display form of a name, but this is currently only done for a Mac OS X type configuration.
Files
All files in the file system are an instance ofinvalid reference
File
There are three types of files:
Directory- contains a table linking file names to.invalid reference
directory entries
RegularFile- an in-memory store for raw bytes.-
- contains a path.
invalid reference
SymbolicLink
invalid reference
ZeroFsFileChannelinvalid reference
ZeroFsInputStreaminvalid reference
ZeroFsOutputStream
invalid reference
ZeroFsSecureDirectoryStream
FileSystemView with its directory as the working directory, allowing for operations relative to
the actual directory file rather than just the path to the file. This allows the operations to
continue to work as expected even if the directory is moved.
A directory can be watched for changes using the WatchService
implementation,
invalid reference
PollingWatchService
Regular files
RegularFile makes use of a singleton
invalid reference
HeapDisk
Linking
When a file is mapped to a file name in a directory table, it is linked. Each type of file has different rules governing how it is linked.- Directory - A directory has two or more links to it. The first is the link from its parent directory to it. This link is the name of the directory. The second is the self link (".") which links the directory to itself. The directory may also have any number of additional parent links ("..") from child directories back to it.
- Regular file - A regular file has one link from its parent directory by default. However, regular files are also allowed to have any number of additional user-created hard links, from the same directory with different names and/or from other directories with any names.
- Symbolic link - A symbolic link can only have one link, from its parent directory.
Thread safety
All file system operations should be safe in a multithreaded environment. The file hierarchy itself is protected by a file system level read-write lock. This ensures safety of all modifications to directory tables as well as atomicity of operations like file moves. Regular files are each protected by a read-write lock which is obtained for each read or write operation. File attributes are protected by synchronization on the file object itself.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ExecutorServiceprivate final FileSystemViewprivate final ZeroFsFileStoreprivate final PathServiceprivate final ZeroFsFileSystemProviderprivate final URIprivate final UserPrincipalLookupServiceprivate final WatchServiceConfiguration -
Constructor Summary
ConstructorsConstructorDescriptionZeroFsFileSystem(ZeroFsFileSystemProvider provider, URI uri, ZeroFsFileStore fileStore, PathService pathService, FileSystemView defaultView, WatchServiceConfiguration watchServiceConfig) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Returns a default thread pool to use for asynchronous file channels when users do not provide an executor themselves.Returns the default view for this file system.Returns the file store for this file system.getPathMatcher(String syntaxAndPattern) (package private) PathServiceReturns the path service for this file system.getUri()Returns the URI for this file system.Returns the working directory path for this file system.booleanisOpen()booleanReturnsfalse; currently, cannot create a read-only file system.provider()Converts the given URI into a path in this file system.toUri(ZeroFsPath path) Gets the URI of the given path in this file system.
-
Field Details
-
provider
-
uri
-
fileStore
-
pathService
-
userLookupService
-
defaultView
-
watchServiceConfig
-
defaultThreadPool
-
-
Constructor Details
-
ZeroFsFileSystem
ZeroFsFileSystem(ZeroFsFileSystemProvider provider, URI uri, ZeroFsFileStore fileStore, PathService pathService, FileSystemView defaultView, WatchServiceConfiguration watchServiceConfig)
-
-
Method Details
-
provider
- Specified by:
providerin classFileSystem
-
getUri
Returns the URI for this file system. -
getDefaultView
Returns the default view for this file system. -
getSeparator
- Specified by:
getSeparatorin classFileSystem
-
getRootDirectories
- Specified by:
getRootDirectoriesin classFileSystem
-
getWorkingDirectory
Returns the working directory path for this file system. -
getPathService
PathService getPathService()Returns the path service for this file system. -
getFileStore
Returns the file store for this file system. -
getFileStores
- Specified by:
getFileStoresin classFileSystem
-
supportedFileAttributeViews
- Specified by:
supportedFileAttributeViewsin classFileSystem
-
getPath
- Specified by:
getPathin classFileSystem
-
toUri
Gets the URI of the given path in this file system. -
toPath
Converts the given URI into a path in this file system. -
getPathMatcher
- Specified by:
getPathMatcherin classFileSystem
-
getUserPrincipalLookupService
- Specified by:
getUserPrincipalLookupServicein classFileSystem
-
newWatchService
- Specified by:
newWatchServicein classFileSystem- Throws:
IOException
-
getDefaultThreadPool
Returns a default thread pool to use for asynchronous file channels when users do not provide an executor themselves. (This is required by the spec of newAsynchronousFileChannel in FileSystemProvider.) -
isReadOnly
public boolean isReadOnly()Returnsfalse; currently, cannot create a read-only file system.- Specified by:
isReadOnlyin classFileSystem- Returns:
false, always
-
isOpen
public boolean isOpen()- Specified by:
isOpenin classFileSystem
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classFileSystem- Throws:
IOException
-