- All Known Implementing Classes:
FileSystemWrapper
,JavaFileSystem
,RandomFailFileSystem
,ReadOnlyFileSystem
,TempFileSystem
public interface FileSystem
The most basic layer of what all file systems have in common.
Every file system is forced to be case-sensitive, even if there is great overhead in doing so.
We know this is in some ways redundant with the java.nio.file
package released in Java 1.7. We are looking for something with a much
different (and narrower) focus, such as hiding differences between platforms
and trying to hide security gotchas.
- Author:
- AO Industries, Inc.
-
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.default 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.default Path
Parses a string representation of a path.long
Gets the size of the file system object at the given path.
-
Method Details
-
checkSubPath
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.- Parameters:
name
- The path to check, must be from this file system.- Throws:
InvalidPathException
- If the path is not acceptable
-
join
Joins the array of names to a path object. Stops at the end of the array or the firstnull
element.- Throws:
InvalidPathException
- See Also:
-
parsePath
Parses a string representation of a path.- Throws:
InvalidPathException
- See Also:
-
list
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.- 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 directoryIOException
- if an underlying I/O error occurs.
-
delete
Deletes the file system object at the given path.- Parameters:
path
- Must be from this file system.- Throws:
NoSuchFileException
- if the path does not existDirectoryNotEmptyException
- if the path is a directory and is not emptyIOException
- if an underlying I/O error occurs.
-
size
Gets the size of the file system object at the given path.- Parameters:
path
- Must be from this file system.- Throws:
NoSuchFileException
- if the path does not existIOException
- if an underlying I/O error occurs.
-
createFile
Atomically creates an empty file (must not have already existed).- Returns:
- returns the path
- Throws:
UnsupportedOperationException
- if unable to create atomicallyFileAlreadyExistsException
- if file already existsIOException
- if an underlying I/O error occurs.
-
createDirectory
Atomically creates a directory (must not have already existed).- Returns:
- returns the path
- Throws:
UnsupportedOperationException
- if unable to create atomicallyFileAlreadyExistsException
- if file already existsIOException
- if an underlying I/O error occurs.
-
lock
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.- Throws:
NoSuchFileException
- if the path does not existIOException
- if an underlying I/O error occurs.- See Also:
-