java.lang.Object
com.aoapps.io.filesystems.TempFileSystem
- All Implemented Interfaces:
FileSystem
A temporary file system stored in the Java heap.
- Author:
- AO Industries, Inc.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkSubPath
(Path parent, String name) Temporary file systems support all possible paths.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.Lists the children of the given path in no specific order.Locks a file in exclusive mode.long
Gets the size of the file system object at the given path.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.aoapps.io.filesystems.FileSystem
join, parsePath
-
Field Details
-
files
-
-
Constructor Details
-
TempFileSystem
public TempFileSystem()Creates a new temp filesystem.
-
-
Method Details
-
checkSubPath
Temporary file systems support all possible paths.- Specified by:
checkSubPath
in interfaceFileSystem
- Parameters:
name
- The path to check, must be from this file system.
-
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:
NoSuchFileException
- if the path does not existNotDirectoryException
- if the path is not a directory
-
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.
-
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.
-
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
-
createDirectory
Description copied from interface:FileSystem
Atomically creates a directory (must not have already existed).- Specified by:
createDirectory
in interfaceFileSystem
- Returns:
- returns the path
-
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
- See Also:
-