Documentation ¶
Index ¶
- Variables
- func ExistsDir(path string) bool
- func ExistsFile(path string) bool
- func ExistsPath(path string) bool
- func ReadBOFMark(rd io.ReadSeeker, pos int64) error
- func ReadUint64(rd io.Reader) (uint64, error)
- func WriteBOFMark(wr io.Writer) error
- func WriteBytes(wr io.Writer, data []byte) error
- func WriteString(wr io.Writer, s string) error
- func WriteUint64(wr io.Writer, num uint64) error
- type File
Constants ¶
This section is empty.
Variables ¶
var BOFMark = []byte{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x23, 0x7E, 0x91, 0x4D, 0x2E, 0xE0, 0x43, 0x1A,
}
BOFMark is the Beginning-Of-File Marker. A magic sequence of bytes written before the metadata and content of every file in the archive.
So, if a part of the archive is partially damaged, the program will be able to recover all intact files.
Functions ¶
func ExistsFile ¶
ExistsFile returns true if a file exists, or false otherwise.
func ExistsPath ¶
ExistsPath returns true if a path exists, or false otherwise.
func ReadBOFMark ¶
func ReadBOFMark(rd io.ReadSeeker, pos int64) error
ReadBOFMark attempts to read the Beginning-Of-File Marker from the reader 'rd' at the position specified by 'pos'.
When it succeeds, moves the reader's position to pos+len(BOFMark). When it fails, it attempts to move to 'pos'.
Returns nil if successful, or an error if the marker could not be read.
func ReadUint64 ¶
ReadUint64 reads a uint64 number from reader 'rd'.
The number should have been previously written by WriteUint64(). See WriteUint64() for more details how these numbers are stored to conserve space.
func WriteBOFMark ¶
WriteBOFMark writes the Beginning-Of-File Marker to writer 'wr'.
func WriteBytes ¶
WriteBytes writes the bytes in 'data' to writer 'wr'.
func WriteString ¶
WriteString writes a string to writer 'wr'.
func WriteUint64 ¶
WriteUint64 writes a uint64 value to writer 'wr' using the minimum number of bytes.
The written bytes consist of two parts:
* The first byte specifies the number of additional bytes needed to store the unsigned. It can range from 0 (for 0) to 8 bytes for largest numbers.
* The second part contains from 0 to 8 bytes that represent the number.
The function saves space provided most numbers are not large: 0 only needs 1 byte, 0-255 only needs two bytes, etc. But math.MaxUint64 would need 9 bytes instead of 8.
Types ¶
type File ¶
File holds file information and content.
func ReadArchivedFile ¶
func ReadArchivedFile( rd io.ReadSeeker, pos int64, loadContent bool, enc *security.Encryption, ) ( *File, error, )
ReadArchivedFile creates a File by reading and decrypting it from an open archive file (the 'rd' reader) at the specified position.
If 'loadContent' is true, loads the file's contents, otherwise only reads the file's metadata (size, path, etc.)
func ReadFile ¶
ReadFile reads a file from the specified path and creates a new File object containing the file's properties and data.
func (*File) SetRelativePath ¶
SetRelativePath adjusts the file's Path by making it relative to the 'path' parameter.
func (*File) WriteEncryptedContent ¶
WriteEncryptedContent writes the file's content to writer 'wr'.
func (*File) WriteEncryptedMetadata ¶
WriteEncryptedMetadata encrypts and writes file metadata to writer 'wr'. The metadata consists of file size, modified time, hash and path.