Class File
- java.lang.Object
-
- org.fedoraproject.xmvn.tools.install.File
-
- Direct Known Subclasses:
Directory
,RegularFile
,SymbolicLink
public abstract class File extends java.lang.Object
An abstract class denoting a file entry in a package with all relevant attributes.A file does not necessarily mean a regular file, it could be for example a directory or a device file.
-
-
Field Summary
Fields Modifier and Type Field Description private int
accessMode
Unix access mode (an integer in range from 0 to 0777).(package private) static int
DEFAULT_MODE
(package private) static int
DIRECTORY_MODE
(package private) static int
MAX_MODE
private java.nio.file.Path
targetPath
Path to target file.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object rhs)
int
getAccessMode()
Get Unix access mode for this file.java.lang.String
getDescriptor()
Get descriptor string for given file.protected java.lang.String
getDescriptorExtra()
Get additional file attributes to be added to file descriptor.java.nio.file.Path
getTargetPath()
Return path to target file.int
hashCode()
void
install(java.nio.file.Path installRoot)
Install file into specified root directory.protected abstract void
installContents(java.nio.file.Path targetAbsolutePath)
Install the file into specified location.
-
-
-
Field Detail
-
DEFAULT_MODE
static final int DEFAULT_MODE
- See Also:
- Constant Field Values
-
DIRECTORY_MODE
static final int DIRECTORY_MODE
- See Also:
- Constant Field Values
-
MAX_MODE
static final int MAX_MODE
- See Also:
- Constant Field Values
-
targetPath
private final java.nio.file.Path targetPath
Path to target file. This path must be relative to buildroot (must not be absolute).
-
accessMode
private final int accessMode
Unix access mode (an integer in range from 0 to 0777).
-
-
Constructor Detail
-
File
public File(java.nio.file.Path targetPath)
Create a file object with specified path and default access mode of 0644.- Parameters:
targetPath
- file path, relative to installation root
-
File
public File(java.nio.file.Path targetPath, int accessMode)
Create a file object with specified path and access mode.- Parameters:
targetPath
- file path, relative to installation rootaccessMode
- Unix access mode of the file (must be an integer in range from 0 to 0777)
-
-
Method Detail
-
installContents
protected abstract void installContents(java.nio.file.Path targetAbsolutePath) throws java.io.IOException
Install the file into specified location.Implementations of this method can assume that all parent directory of target file already exists. Access mode of target file doesn't have to be set as it will be manipulated with other means.
- Parameters:
targetAbsolutePath
- absolute path to the target file- Throws:
java.io.IOException
-
getDescriptorExtra
protected java.lang.String getDescriptorExtra()
Get additional file attributes to be added to file descriptor.By default there are no extra attributes, but subclasses can override this method and specify it.
- Returns:
- extra descriptor data (can be
null
)
-
getTargetPath
public java.nio.file.Path getTargetPath()
Return path to target file. Returned path is always relative to buildroot (never absolute).- Returns:
- file target path (never
null
)
-
getAccessMode
public int getAccessMode()
Get Unix access mode for this file.- Returns:
- Unix access mode (an integer in range from 0 to 0777)
-
install
public void install(java.nio.file.Path installRoot) throws java.io.IOException
Install file into specified root directory.- Parameters:
installRoot
-- Throws:
java.io.IOException
-
getDescriptor
public java.lang.String getDescriptor()
Get descriptor string for given file.Descriptor is a line containing file path and some attributes. In other words, descriptor is a single line from
.mfiles
describing the file.- Returns:
- descriptor string
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object rhs)
- Overrides:
equals
in classjava.lang.Object
-
-