Package com.github.junrar.rarfile
Class FileHeader
- java.lang.Object
-
- com.github.junrar.rarfile.BaseBlock
-
- com.github.junrar.rarfile.BlockHeader
-
- com.github.junrar.rarfile.FileHeader
-
public class FileHeader extends BlockHeader
DOCUMENT ME- Version:
- $LastChangedRevision$
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classFileHeader.TimePositionTuple
-
Field Summary
Fields Modifier and Type Field Description private java.nio.file.attribute.FileTimearcTimeprivate java.nio.file.attribute.FileTimeaTimeprivate java.nio.file.attribute.FileTimecTimeprivate intfileAttrprivate intfileCRCprivate java.lang.StringfileNameprivate byte[]fileNameBytesprivate java.lang.StringfileNameWprivate longfullPackSizeprivate longfullUnpackSizeprivate inthighPackSizeprivate inthighUnpackSizeprivate HostSystemhostOSprivate static org.slf4j.Loggerloggerprivate java.nio.file.attribute.FileTimemTimeprivate shortnameSizeprivate static longNANOS_PER_UNITprivate static byteNEWLHD_SIZEprivate intrecoverySectorsprivate byte[]saltprivate static byteSALT_SIZEprivate byte[]subDataprivate intsubFlagsprivate byteunpMethodprivate longunpSizeprivate byteunpVersion-
Fields inherited from class com.github.junrar.rarfile.BlockHeader
blockHeaderSize
-
Fields inherited from class com.github.junrar.rarfile.BaseBlock
BaseBlockSize, EARC_DATACRC, EARC_NEXT_VOLUME, EARC_REVSPACE, EARC_VOLNUMBER, flags, headCRC, headerSize, headerType, LHD_COMMENT, LHD_DIRECTORY, LHD_EXTFLAGS, LHD_EXTTIME, LHD_LARGE, LHD_PASSWORD, LHD_SALT, LHD_SOLID, LHD_SPLIT_AFTER, LHD_SPLIT_BEFORE, LHD_UNICODE, LHD_VERSION, LHD_WINDOW1024, LHD_WINDOW128, LHD_WINDOW2048, LHD_WINDOW256, LHD_WINDOW4096, LHD_WINDOW512, LHD_WINDOW64, LHD_WINDOWMASK, LONG_BLOCK, MHD_AV, MHD_COMMENT, MHD_ENCRYPTVER, MHD_FIRSTVOLUME, MHD_LOCK, MHD_NEWNUMBERING, MHD_PACK_COMMENT, MHD_PASSWORD, MHD_PROTECT, MHD_SOLID, MHD_VOLUME, positionInFile, SKIP_IF_UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description FileHeader(BlockHeader bh, byte[] fileHeader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.nio.file.attribute.FileTimegetArchivalTime()The time in which the file was archived.java.util.DategetArcTime()GetsgetArchivalTime()as aDate.java.util.DategetATime()GetsgetLastAccessTime()as aDate.java.nio.file.attribute.FileTimegetCreationTime()The time in which the file was created.java.util.DategetCTime()GetsgetCreationTime()as aDate.private static longgetDateDos(int time)intgetFileAttr()intgetFileCRC()java.lang.StringgetFileName()The filename either in Unicode or ASCII.byte[]getFileNameByteArray()java.lang.StringgetFileNameString()Deprecated.As of 7.2.0, replaced bygetFileName()java.lang.StringgetFileNameW()Deprecated.As of 7.2.0, replaced bygetFileName()longgetFullPackSize()longgetFullUnpackSize()intgetHighPackSize()intgetHighUnpackSize()HostSystemgetHostOS()java.nio.file.attribute.FileTimegetLastAccessTime()The time in which the file was last accessed.java.nio.file.attribute.FileTimegetLastModifiedTime()The time in which the file was last modified.java.util.DategetMTime()GetsgetLastModifiedTime()as aDate.shortgetNameSize()intgetRecoverySectors()byte[]getSalt()byte[]getSubData()intgetSubFlags()bytegetUnpMethod()longgetUnpSize()bytegetUnpVersion()booleanhasExtTime()booleanhasSalt()booleanisDirectory()whether this fileheader represents a directorybooleanisEncrypted()the file is encryptedbooleanisFileHeader()private static booleanisFilenameValid(java.lang.String filename)booleanisLargeBlock()booleanisSolid()this file is compressed as solid (all files handeled as one)booleanisSplitAfter()the file will be continued in the next archive partbooleanisSplitBefore()the file is continued in this archivebooleanisUnicode()the filename is also present in unicodeprivate static FileHeader.TimePositionTupleparseExtTime(int shift, short flags, byte[] fileHeader, int position)private static FileHeader.TimePositionTupleparseExtTime(int shift, short flags, byte[] fileHeader, int position, java.nio.file.attribute.FileTime baseTime)voidprint()voidsetArchivalTime(java.nio.file.attribute.FileTime archivalTime)Sets the time in which the file was archived.voidsetArcTime(java.util.Date arcTime)SetssetArchivalTime(FileTime)from aDate.voidsetATime(java.util.Date time)SetssetLastAccessTime(FileTime)from aDate.voidsetCreationTime(java.nio.file.attribute.FileTime time)Sets the time in which the file was created.voidsetCTime(java.util.Date time)SetssetCreationTime(FileTime)from aDate.voidsetFileAttr(int fileAttr)voidsetFileName(java.lang.String fileName)voidsetFileNameW(java.lang.String fileNameW)voidsetLastAccessTime(java.nio.file.attribute.FileTime time)Sets the time in which the file was last accessed.voidsetLastModifiedTime(java.nio.file.attribute.FileTime time)Sets the time in which the file was last modified.voidsetMTime(java.util.Date time)SetssetLastModifiedTime(FileTime)from aDate.private static java.util.DatetoDate(java.nio.file.attribute.FileTime time)private static java.nio.file.attribute.FileTimetoFileTime(java.util.Date time)java.lang.StringtoString()-
Methods inherited from class com.github.junrar.rarfile.BlockHeader
getDataSize, getPackSize
-
Methods inherited from class com.github.junrar.rarfile.BaseBlock
getFlags, getHeadCRC, getHeaderSize, getHeaderSize, getHeaderType, getPositionInFile, hasArchiveDataCRC, hasEncryptVersion, hasVolumeNumber, isSubBlock, setPositionInFile
-
-
-
-
Field Detail
-
logger
private static final org.slf4j.Logger logger
-
SALT_SIZE
private static final byte SALT_SIZE
- See Also:
- Constant Field Values
-
NEWLHD_SIZE
private static final byte NEWLHD_SIZE
- See Also:
- Constant Field Values
-
NANOS_PER_UNIT
private static final long NANOS_PER_UNIT
- See Also:
- Constant Field Values
-
unpSize
private final long unpSize
-
hostOS
private final HostSystem hostOS
-
fileCRC
private final int fileCRC
-
unpVersion
private byte unpVersion
-
unpMethod
private byte unpMethod
-
nameSize
private short nameSize
-
highPackSize
private final int highPackSize
-
highUnpackSize
private int highUnpackSize
-
fileNameBytes
private final byte[] fileNameBytes
-
fileName
private java.lang.String fileName
-
fileNameW
private java.lang.String fileNameW
-
subData
private byte[] subData
-
salt
private final byte[] salt
-
mTime
private java.nio.file.attribute.FileTime mTime
-
cTime
private java.nio.file.attribute.FileTime cTime
-
aTime
private java.nio.file.attribute.FileTime aTime
-
arcTime
private java.nio.file.attribute.FileTime arcTime
-
fullPackSize
private long fullPackSize
-
fullUnpackSize
private long fullUnpackSize
-
fileAttr
private int fileAttr
-
subFlags
private int subFlags
-
recoverySectors
private int recoverySectors
-
-
Constructor Detail
-
FileHeader
public FileHeader(BlockHeader bh, byte[] fileHeader) throws CorruptHeaderException
- Throws:
CorruptHeaderException
-
-
Method Detail
-
isFilenameValid
private static boolean isFilenameValid(java.lang.String filename)
-
parseExtTime
private static FileHeader.TimePositionTuple parseExtTime(int shift, short flags, byte[] fileHeader, int position)
-
parseExtTime
private static FileHeader.TimePositionTuple parseExtTime(int shift, short flags, byte[] fileHeader, int position, java.nio.file.attribute.FileTime baseTime)
-
print
public void print()
- Overrides:
printin classBlockHeader
-
getDateDos
private static long getDateDos(int time)
-
toDate
private static java.util.Date toDate(java.nio.file.attribute.FileTime time)
-
toFileTime
private static java.nio.file.attribute.FileTime toFileTime(java.util.Date time)
-
getArchivalTime
public java.nio.file.attribute.FileTime getArchivalTime()
The time in which the file was archived. Corresponds to tearcTimefield.- Returns:
- the timestamp, or null if absent.
-
setArchivalTime
public void setArchivalTime(java.nio.file.attribute.FileTime archivalTime)
Sets the time in which the file was archived. Corresponds to tearcTimefield.- Parameters:
archivalTime- the timestamp, or null to clear it.
-
getArcTime
public java.util.Date getArcTime()
GetsgetArchivalTime()as aDate. The maximum granularity is reduced from microseconds to milliseconds.- Returns:
- the date, or null if absent.
-
setArcTime
public void setArcTime(java.util.Date arcTime)
SetssetArchivalTime(FileTime)from aDate.- Parameters:
arcTime- the date, or null to clear it.
-
getLastAccessTime
public java.nio.file.attribute.FileTime getLastAccessTime()
The time in which the file was last accessed. Corresponds to teaTimefield.- Returns:
- the timestamp, or null if absent.
-
setLastAccessTime
public void setLastAccessTime(java.nio.file.attribute.FileTime time)
Sets the time in which the file was last accessed. Corresponds to teaTimefield.- Parameters:
time- the timestamp, or null to clear it.
-
getATime
public java.util.Date getATime()
GetsgetLastAccessTime()as aDate. The maximum granularity is reduced from microseconds to milliseconds.- Returns:
- the date, or null if absent.
-
setATime
public void setATime(java.util.Date time)
SetssetLastAccessTime(FileTime)from aDate.- Parameters:
time- the date, or null to clear it.
-
getCreationTime
public java.nio.file.attribute.FileTime getCreationTime()
The time in which the file was created. Corresponds to tecTimefield.- Returns:
- the timestamp, or null if absent.
-
setCreationTime
public void setCreationTime(java.nio.file.attribute.FileTime time)
Sets the time in which the file was created. Corresponds to tecTimefield.- Parameters:
time- the timestamp, or null to clear it.
-
getCTime
public java.util.Date getCTime()
GetsgetCreationTime()as aDate. The maximum granularity is reduced from microseconds to milliseconds.- Returns:
- the date, or null if absent.
-
setCTime
public void setCTime(java.util.Date time)
SetssetCreationTime(FileTime)from aDate.- Parameters:
time- the date, or null to clear it.
-
getFileAttr
public int getFileAttr()
-
setFileAttr
public void setFileAttr(int fileAttr)
-
getFileCRC
public int getFileCRC()
-
getFileNameByteArray
public byte[] getFileNameByteArray()
-
getFileNameString
@Deprecated public java.lang.String getFileNameString()
Deprecated.As of 7.2.0, replaced bygetFileName()The ASCII filename.- Returns:
- the ASCII filename
-
setFileName
public void setFileName(java.lang.String fileName)
-
getFileNameW
@Deprecated public java.lang.String getFileNameW()
Deprecated.As of 7.2.0, replaced bygetFileName()The unicode filename.- Returns:
- the Unicode filename, or null if the filename is ASCII only
-
setFileNameW
public void setFileNameW(java.lang.String fileNameW)
-
getHighPackSize
public int getHighPackSize()
-
getHighUnpackSize
public int getHighUnpackSize()
-
getHostOS
public HostSystem getHostOS()
-
getLastModifiedTime
public java.nio.file.attribute.FileTime getLastModifiedTime()
The time in which the file was last modified. Corresponds to temTimefield.- Returns:
- the timestamp, or null if absent.
-
setLastModifiedTime
public void setLastModifiedTime(java.nio.file.attribute.FileTime time)
Sets the time in which the file was last modified. Corresponds to temTimefield.- Parameters:
time- the timestamp, or null to clear it.
-
getMTime
public java.util.Date getMTime()
GetsgetLastModifiedTime()as aDate. The maximum granularity is reduced from microseconds to milliseconds.- Returns:
- the date, or null if absent.
-
setMTime
public void setMTime(java.util.Date time)
SetssetLastModifiedTime(FileTime)from aDate.- Parameters:
time- the date, or null to clear it.
-
getNameSize
public short getNameSize()
-
getRecoverySectors
public int getRecoverySectors()
-
getSalt
public byte[] getSalt()
-
getSubData
public byte[] getSubData()
-
getSubFlags
public int getSubFlags()
-
getUnpMethod
public byte getUnpMethod()
-
getUnpSize
public long getUnpSize()
-
getUnpVersion
public byte getUnpVersion()
-
getFullPackSize
public long getFullPackSize()
-
getFullUnpackSize
public long getFullUnpackSize()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isSplitAfter
public boolean isSplitAfter()
the file will be continued in the next archive part- Returns:
- isSplitAfter
-
isSplitBefore
public boolean isSplitBefore()
the file is continued in this archive- Returns:
- isSplitBefore
-
isSolid
public boolean isSolid()
this file is compressed as solid (all files handeled as one)- Returns:
- isSolid
-
isEncrypted
public boolean isEncrypted()
the file is encrypted- Returns:
- isEncrypted
-
isUnicode
public boolean isUnicode()
the filename is also present in unicode- Returns:
- isUnicode
-
isFileHeader
public boolean isFileHeader()
-
hasSalt
public boolean hasSalt()
-
hasExtTime
public boolean hasExtTime()
-
isLargeBlock
public boolean isLargeBlock()
-
isDirectory
public boolean isDirectory()
whether this fileheader represents a directory- Returns:
- isDirectory
-
getFileName
public java.lang.String getFileName()
The filename either in Unicode or ASCII.- Returns:
- the Unicode filename if it exists, else the ASCII filename
- Since:
- 7.2.0
-
-