XU XUv0.16.0

#archive/tar

import: #archive/tar

counts: 5 functions, 10 methods, 4 types, 9 constants, 0 method sets

ustar subset: Header + Reader/Writer. Archives are owning strings.

const BLOCK_SIZE

XuAPI
pub const BLOCK_SIZE = 512

Purpose

Constant BLOCK_SIZE, defining protocol or algorithm parameters.

const TYPE_REG

XuAPI
pub const TYPE_REG = 48

Purpose

Constant TYPE_REG, defining protocol or algorithm parameters.

const TYPE_DIR

XuAPI
pub const TYPE_DIR = 53

Purpose

Constant TYPE_DIR, defining protocol or algorithm parameters.

const TYPE_GNU_LONGNAME

XuAPI
pub const TYPE_GNU_LONGNAME = 76

Purpose

Constant TYPE_GNU_LONGNAME, defining protocol or algorithm parameters.

const TYPE_XHEADER

XuAPI
pub const TYPE_XHEADER = 120

Purpose

Constant TYPE_XHEADER, defining protocol or algorithm parameters.

const TYPE_XGLOBAL_HEADER

XuAPI
pub const TYPE_XGLOBAL_HEADER = 103

Purpose

Constant TYPE_XGLOBAL_HEADER, defining protocol or algorithm parameters.

struct Header

XuAPI
pub struct Header {
    pub name string
    pub size int
    pub mode int
    pub typeflag int
    pub linkname string
    pub uname string
    pub gname string
    pub mtime int
}

Purpose

Tar Metadata header descriptor structure.

Public fields

name string
name
size int
field (int)
mode int
mode
typeflag int
field (int)
linkname string
field (string)
uname string
field (string)
gname string
field (string)
mtime int
field (int)

struct File

XuAPI
pub struct File {
    pub name string
    pub size int
    pub mode int
    pub typeflag int
    pub linkname string
    pub uname string
    pub gname string
    pub mtime int
    pub body string
}

Purpose

Structure encapsulating name, size, mode, typeflag, linkname.

Public fields

name string
name
size int
field (int)
mode int
mode
typeflag int
field (int)
linkname string
field (string)
uname string
field (string)
gname string
field (string)
mtime int
field (int)
body string
body

struct Reader

XuAPI
pub struct Reader {
    pub data string
    pub pos int
}

Purpose

Tar Streaming reader and decoder.

Public fields

data string
data
pos int
field (int)

struct Writer

XuAPI
pub struct Writer {
    pub buf string
    pub closed int
    pub nfiles int
}

Purpose

Tar Streaming writer and encoder.

Public fields

buf string
buffer
closed int
field (int)
nfiles int
field (int)

new_header

XuAPI
pub fn new_header() Header

Purpose

Construct header.

Parameters

No arguments are required.

Returns

Header — a value of this type

new_reader

XuAPI
pub fn new_reader(data &string) Reader

Purpose

Construct reader.

Parameters

data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

Reader — a value of this type

new_writer

XuAPI
pub fn new_writer() Writer

Purpose

Construct writer.

Parameters

No arguments are required.

Returns

Writer — a value of this type

(&Writer) file_count

XuAPI
pub fn (w &Writer) file_count() int

Purpose

Operation on &Writer: file count.

Parameters

w &Writer
The Writer instance used by this call (borrow).

Returns

int — a value of this type

encode_header

XuAPI
pub fn encode_header(h &Header) string

Purpose

Encode header data. Throws on failure; handle the error or propagate it to the caller.

Parameters

h &Header
height or handle (read-only borrow; caller keeps the original; type &Header)

Returns

string — result string

parse_header

XuAPI
pub fn parse_header(blk &string) Header

Purpose

Parse as header. Throws on failure; handle the error or propagate it to the caller.

Parameters

blk &string
blk (read-only borrow; caller keeps the original; type &string)

Returns

Header — a value of this type

($&Reader) next

XuAPI
pub fn (r $&Reader) next() File

Purpose

Operation on $&Reader: take the next item, or end according to this type. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&Reader
The Reader instance used by this call (exclusive borrow).

Returns

File — a value of this type

(&Writer) bytes

XuAPI
pub fn (w &Writer) bytes() string

Purpose

Operation on &Writer: return the buffered bytes.

Parameters

w &Writer
The Writer instance used by this call (borrow).

Returns

string — result string

($&Writer) write_header

XuAPI
pub fn (w $&Writer) write_header(h &Header, body &string) int

Purpose

Operation on $&Writer: write header. Throws on failure; handle the error or propagate it to the caller.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
h &Header
height or handle (read-only borrow; caller keeps the original; type &Header)
body &string
body (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

($&Writer) write_file

XuAPI
pub fn (w $&Writer) write_file(name &string, body &string, mode int) int

Purpose

Operation on $&Writer: write file. Throws on failure; handle the error or propagate it to the caller.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
name &string
name (read-only borrow; caller keeps the original; type &string)
body &string
body (read-only borrow; caller keeps the original; type &string)
mode int
mode (int)

Returns

int — a value of this type

($&Writer) write_dir

XuAPI
pub fn (w $&Writer) write_dir(name &string, mode int) int

Purpose

Operation on $&Writer: write directory. Throws on failure; handle the error or propagate it to the caller.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
name &string
name (read-only borrow; caller keeps the original; type &string)
mode int
mode (int)

Returns

int — a value of this type

($&Writer) close

XuAPI
pub fn (w $&Writer) close() int

Purpose

Operation on $&Writer: close the resource.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).

Returns

int — a value of this type

($&Writer) write_entry_header

XuAPI
pub fn (w $&Writer) write_entry_header(h &Header) int

Purpose

write_entry_header writes the 512-byte USTAR / GNU header for streaming body writes. Throws on failure; handle the error or propagate it to the caller.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
h &Header
height or handle (read-only borrow; caller keeps the original; type &Header)

Returns

int — a value of this type

($&Writer) write_chunk

XuAPI
pub fn (w $&Writer) write_chunk(chunk &string) int

Purpose

write_chunk streams a chunk of the current file body into the archive. Throws on failure; handle the error or propagate it to the caller.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
chunk &string
chunk (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

($&Writer) finish_entry

XuAPI
pub fn (w $&Writer) finish_entry(file_size int) int

Purpose

finish_entry pads the current entry to a 512-byte block boundary. Throws on failure; handle the error or propagate it to the caller.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
file_size int
file_size (int)

Returns

int — a value of this type