@obsidize/tar-browserify
Version:
Browser-based tar utility for packing and unpacking tar files (stream-capable)
86 lines (85 loc) • 3.18 kB
TypeScript
import { TarSerializable } from '../common/tar-utility';
import { PaxHeader } from './pax/pax-header';
import { UstarHeader } from './ustar/ustar-header';
import { UstarHeaderLike } from './ustar/ustar-header-like';
import { UstarHeaderLinkIndicatorType } from './ustar/ustar-header-link-indicator-type';
export interface TarHeaderOptions {
ustar: UstarHeader;
pax?: PaxHeader;
preamble?: UstarHeader;
isPaxGlobal?: boolean;
}
/**
* Facade over a backing Uint8Array buffer to consume/edit header data
* at a specific location in the buffer.
*
* Does not perform any mutations or reads on creation, and
* lazy loads/sets data via getters and setters.
*/
export declare class TarHeader implements UstarHeaderLike, TarSerializable {
readonly ustar: UstarHeader;
readonly pax: PaxHeader | undefined;
private mPreamble;
private mIsGlobal;
constructor(options: TarHeaderOptions);
static isTarHeader(value: any): boolean;
/**
* @returns A new `TarHeader` instance based on the given attributes (if they are a POJO).
* Note that if the given value is already a TarHeader instance, this will return it as-is.
*/
static fromAttributes(attributes: Partial<UstarHeaderLike>): TarHeader;
/**
* Short-hand for constructing a new `TarHeader` and immediately calling `toUint8Array()` on it
*/
static serializeAttributes(attributes: Partial<UstarHeaderLike>): Uint8Array;
private static collectPaxRequiredAttributes;
private static splitBaseFileName;
get preamble(): UstarHeader | undefined;
get fileName(): string;
get fileMode(): number;
get ownerUserId(): number;
get groupUserId(): number;
get fileSize(): number;
get lastModified(): number;
get headerChecksum(): number;
get linkedFileName(): string;
get typeFlag(): UstarHeaderLinkIndicatorType;
get ustarIndicator(): string;
get ustarVersion(): string;
get ownerUserName(): string;
get ownerGroupName(): string;
get deviceMajorNumber(): string;
get deviceMinorNumber(): string;
get fileNamePrefix(): string;
get isPaxHeader(): boolean;
get isGlobalPaxHeader(): boolean;
get isLocalPaxHeader(): boolean;
get isGlobalPaxPreHeader(): boolean;
get isLocalPaxPreHeader(): boolean;
get isGlobalPaxPostHeader(): boolean;
get isLocalPaxPostHeader(): boolean;
get isFileHeader(): boolean;
get isDirectoryHeader(): boolean;
/**
* Removes any unknown or un-standardized keys from
* the PAX portion of this header (if one exists).
*
* See also `PaxHeader.clean()`.
*
* @returns `this` for operation chaining
*/
clean(): this;
/**
* Ensures that things such as checksum values are
* synchronized with the current underlying header states.
*
* @returns `this` for operation chaining
*/
private normalize;
/**
* @returns A snapshot of the underlying buffer for this header
*/
toUint8Array(): Uint8Array;
toJSON(): Record<string, unknown>;
private trySyncPaxHeader;
}