Package com.google.common.jimfs
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) void
closed()
Called when a stream or channel to this file is closed.(package private) @Nullable ReadWriteLock
Returns the read-write lock for this file's content, ornull
if there is no content lock.(package private) final void
copyAttributes
(File target) Copies the attributes from this file to the given file.(package private) final void
copyBasicAttributes
(File target) Copies basic attributes (file times) from this file to the given file.(package private) void
copyContentTo
(File file) Copies the content of this file to the given file.(package private) abstract File
copyWithoutContent
(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 void
Decrements the link count for this file.final void
deleteAttribute
(String view, String attribute) Deletes the given attribute from the given view.(package private) void
deleted()
Called when (a single link to) this file is deleted.final @Nullable Object
getAttribute
(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 FileTime
Gets the creation time of the file.final FileTime
Gets the last access time of the file.final FileTime
Gets the last modified time of the file.int
id()
Returns the ID of this file.(package private) final void
Increments the link count for this file.final boolean
Returns whether or not this file is a directory.final boolean
Returns whether or not this file is a regular file.(package private) final boolean
Returns whether or not this file is a root directory of the file system.final boolean
Returns whether or not this file is a symbolic link.(package private) void
linked
(DirectoryEntry entry) Called when this file has been linked in a directory.final int
links()
Returns the current count of links to this file.(package private) void
opened()
Called when a stream or channel to this file is opened.private void
final void
setAttribute
(String view, String attribute, Object value) Sets the given attribute in the given view to the given value.(package private) final void
setCreationTime
(FileTime creationTime) Sets the creation time of the file.private void
setFileTimes
(FileTime creationTime, FileTime lastModifiedTime, FileTime lastAccessTime) (package private) final void
setLastAccessTime
(FileTime lastAccessTime) Sets the last access time of the file.(package private) final void
setLastModifiedTime
(FileTime lastModifiedTime) Sets the last modified time of the file.long
size()
Returns the size, in bytes, of this file's content.final String
toString()
(package private) void
unlinked()
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, ornull
if 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
Returns the names of the attributes contained in the given attribute view in the file's attributes table. -
getAttributeKeys
Returns the attribute keys contained in the attributes map for the file. -
getAttribute
Gets the value of the given attribute in the given view. -
setAttribute
Sets the given attribute in the given view to the given value. -
deleteAttribute
Deletes the given attribute from the given view. -
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
-