Class File
java.lang.Object
com.google.common.jimfs.File
- Direct Known Subclasses:
Directory, RegularFile, SymbolicLink
A file object, containing both the file's metadata and content.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidclosed()Called when a stream or channel to this file is closed.(package private) @Nullable ReadWriteLockReturns the read-write lock for this file's content, ornullif there is no content lock.(package private) final voidcopyAttributes(File target) Copies the attributes from this file to the given file.(package private) final voidcopyBasicAttributes(File target) Copies basic attributes (file times) from this file to the given file.(package private) voidcopyContentTo(File file) Copies the content of this file to the given file.(package private) abstract FilecopyWithoutContent(int id, FileTime creationTime) Creates a new file of the same type as this file with the given ID and creation time.(package private) final voidDecrements the link count for this file.final voiddeleteAttribute(String view, String attribute) Deletes the given attribute from the given view.(package private) voiddeleted()Called when (a single link to) this file is deleted.final @Nullable ObjectgetAttribute(String view, String attribute) Gets the value of the given attribute in the given view.(package private) final com.google.common.collect.ImmutableSet<String> Returns the attribute keys contained in the attributes map for the file.final com.google.common.collect.ImmutableSet<String> getAttributeNames(String view) Returns the names of the attributes contained in the given attribute view in the file's attributes table.final FileTimeGets the creation time of the file.final FileTimeGets the last access time of the file.final FileTimeGets the last modified time of the file.intid()Returns the ID of this file.(package private) final voidIncrements the link count for this file.final booleanReturns whether or not this file is a directory.final booleanReturns whether or not this file is a regular file.(package private) final booleanReturns whether or not this file is a root directory of the file system.final booleanReturns whether or not this file is a symbolic link.(package private) voidlinked(DirectoryEntry entry) Called when this file has been linked in a directory.final intlinks()Returns the current count of links to this file.(package private) voidopened()Called when a stream or channel to this file is opened.private voidfinal voidsetAttribute(String view, String attribute, Object value) Sets the given attribute in the given view to the given value.(package private) final voidsetCreationTime(FileTime creationTime) Sets the creation time of the file.private voidsetFileTimes(FileTime creationTime, FileTime lastModifiedTime, FileTime lastAccessTime) (package private) final voidsetLastAccessTime(FileTime lastAccessTime) Sets the last access time of the file.(package private) final voidsetLastModifiedTime(FileTime lastModifiedTime) Sets the last modified time of the file.longsize()Returns the size, in bytes, of this file's content.final StringtoString()(package private) voidunlinked()Called when this file has been unlinked from a directory, either for a move or delete.
-
Field Details
-
id
private final int id -
links
private int links -
creationTime
-
lastAccessTime
-
lastModifiedTime
-
attributes
-
-
Constructor Details
-
File
File(int id, FileTime creationTime)
-
-
Method Details
-
id
public int id()Returns the ID of this file. -
size
public long size()Returns the size, in bytes, of this file's content. Directories and symbolic links have a size of 0. -
isDirectory
public final boolean isDirectory()Returns whether or not this file is a directory. -
isRegularFile
public final boolean isRegularFile()Returns whether or not this file is a regular file. -
isSymbolicLink
public final boolean isSymbolicLink()Returns whether or not this file is a symbolic link. -
copyWithoutContent
Creates a new file of the same type as this file with the given ID and creation time. Does not copy the content of this file unless the cost of copying the content is minimal. This is because this method is called with a hold on the file system's lock. -
copyContentTo
Copies the content of this file to the given file. The given file must be the same type of file as this file and should have no content.This method is used for copying the content of a file after copying the file itself. Does nothing by default.
- Throws:
IOException
-
contentLock
@Nullable ReadWriteLock contentLock()Returns the read-write lock for this file's content, ornullif there is no content lock. -
opened
void opened()Called when a stream or channel to this file is opened. -
closed
void closed()Called when a stream or channel to this file is closed. If there are no more streams or channels open to the file and it has been deleted, its contents may be deleted. -
deleted
void deleted()Called when (a single link to) this file is deleted. There may be links remaining. Does nothing by default. -
isRootDirectory
final boolean isRootDirectory()Returns whether or not this file is a root directory of the file system. -
links
public final int links()Returns the current count of links to this file. -
linked
Called when this file has been linked in a directory. The given entry is the new directory entry that links to this file. -
unlinked
void unlinked()Called when this file has been unlinked from a directory, either for a move or delete. -
incrementLinkCount
final void incrementLinkCount()Increments the link count for this file. -
decrementLinkCount
final void decrementLinkCount()Decrements the link count for this file. -
getCreationTime
Gets the creation time of the file. -
getLastAccessTime
Gets the last access time of the file. -
getLastModifiedTime
Gets the last modified time of the file. -
setCreationTime
Sets the creation time of the file. -
setLastAccessTime
Sets the last access time of the file. -
setLastModifiedTime
Sets the last modified time of the file. -
getAttributeNames
-
getAttributeKeys
Returns the attribute keys contained in the attributes map for the file. -
getAttribute
-
setAttribute
-
deleteAttribute
-
copyBasicAttributes
Copies basic attributes (file times) from this file to the given file. -
setFileTimes
-
copyAttributes
Copies the attributes from this file to the given file. -
putAll
-
toString
-