java.lang.Object
com.aoapps.io.filesystems.FileSystemWrapper
- All Implemented Interfaces:
FileSystem
- Direct Known Subclasses:
RandomFailFileSystem
,ReadOnlyFileSystem
A file system that wraps another to intercept and otherwise modify interactions.
- Author:
- AO Industries, Inc.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
WrapsPathIterator
, wrapping each result inFileSystemWrapper.PathIteratorWrapper.next()
.protected static class
Wraps aPath
. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkSubPath
(Path parent, String name) Checks that a given path name is acceptable to this file system.createDirectory
(Path path) Atomically creates a directory (must not have already existed).createFile
(Path path) Atomically creates an empty file (must not have already existed).void
Deletes the file system object at the given path.Joins the array of names to a path object.Lists the children of the given path in no specific order.Locks a file in exclusive mode.Parses a string representation of a path.long
Gets the size of the file system object at the given path.protected Path
unwrapPath
(Path path) Unwraps a path.protected FileSystemWrapper.PathWrapper
Wraps a path.protected FileSystemWrapper.PathWrapper
wrapSubPath
(FileSystemWrapper.PathWrapper parent, Path subPath) Wraps a new sub path.
-
Field Details
-
wrappedFileSystem
-
-
Constructor Details
-
FileSystemWrapper
-
-
Method Details
-
wrapSubPath
protected FileSystemWrapper.PathWrapper wrapSubPath(FileSystemWrapper.PathWrapper parent, Path subPath) Wraps a new sub path. -
wrapPath
Wraps a path. -
unwrapPath
Unwraps a path. -
checkSubPath
Description copied from interface:FileSystem
Checks that a given path name is acceptable to this file system. Regular path rules are already checked, this is for additional file system specific constraints. The root path is never passed here.- Specified by:
checkSubPath
in interfaceFileSystem
- Parameters:
name
- The path to check, must be from this file system.- Throws:
InvalidPathException
- If the path is not acceptable
-
join
Description copied from interface:FileSystem
Joins the array of names to a path object. Stops at the end of the array or the firstnull
element.- Specified by:
join
in interfaceFileSystem
- Throws:
InvalidPathException
- See Also:
-
parsePath
Description copied from interface:FileSystem
Parses a string representation of a path.- Specified by:
parsePath
in interfaceFileSystem
- Throws:
InvalidPathException
- See Also:
-
list
Description copied from interface:FileSystem
Lists the children of the given path in no specific order. It is possible that paths may be returned that no longer exist. It is also possible that new file system objects created after the beginning of iteration are not returned.- Specified by:
list
in interfaceFileSystem
- Parameters:
path
- Must be from this file system.- Returns:
- a read-only iterator of children
- Throws:
IOException
- if an underlying I/O error occurs.
-
delete
Description copied from interface:FileSystem
Deletes the file system object at the given path.- Specified by:
delete
in interfaceFileSystem
- Parameters:
path
- Must be from this file system.- Throws:
IOException
- if an underlying I/O error occurs.
-
size
Description copied from interface:FileSystem
Gets the size of the file system object at the given path.- Specified by:
size
in interfaceFileSystem
- Parameters:
path
- Must be from this file system.- Throws:
IOException
- if an underlying I/O error occurs.
-
createFile
Description copied from interface:FileSystem
Atomically creates an empty file (must not have already existed).- Specified by:
createFile
in interfaceFileSystem
- Returns:
- returns the path
- Throws:
IOException
- if an underlying I/O error occurs.
-
createDirectory
Description copied from interface:FileSystem
Atomically creates a directory (must not have already existed).- Specified by:
createDirectory
in interfaceFileSystem
- Returns:
- returns the path
- Throws:
IOException
- if an underlying I/O error occurs.
-
lock
Description copied from interface:FileSystem
Locks a file in exclusive mode. File range and shared locks not currently supported. The lock must be closed to unlock, usually in a try/finally or try-with-resources block. The locks are not reentrant, attempting to obtain the lock from the same thread will result in deadlock.- Specified by:
lock
in interfaceFileSystem
- Throws:
IOException
- if an underlying I/O error occurs.- See Also:
-