API
#archive/tar
Xu 0.8.8 API
import: #archive/tar
counts: 5 fns, 7 methods, 4 types, 7 consts, 0 ifaces
ustar subset: Header + Reader/Writer. Archives are owning strings.
const block_size
pub const block_size = 512
Purpose
USTAR tar subset aligned with `archive/tar` Header + Reader/Writer common path. Archives are owning strings (no io.Reader). ustar headers plus GNU longname/longlink (`L`/`K`). No PAX, sparse, or streaming FileInfo. Value `512`.
Parameters
none
const type_reg
Purpose
Public constant `type_reg`. Value `48`.
Parameters
none
const type_link
Purpose
Public constant `type_link`. Value `49`.
Parameters
none
const type_symlink
pub const type_symlink = 50
Purpose
Public constant `type_symlink`. Value `50`.
Parameters
none
const type_dir
Purpose
Public constant `type_dir`. Value `53`.
Parameters
none
const type_gnu_longlink
pub const type_gnu_longlink = 75
Purpose
Public constant `type_gnu_longlink`. Value `75`.
Parameters
none
const type_gnu_longname
pub const type_gnu_longname = 76
Purpose
Public constant `type_gnu_longname`. Value `76`.
Parameters
none
struct File
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
Public struct `File`.
Parameters
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
pub struct Reader {
pub data string
pub pos int
}
Purpose
Public struct `Reader`.
Parameters
data string- data
pos int- field (int)
struct Writer
pub struct Writer {
pub buf string
pub closed int
pub nfiles int
}
Purpose
Public struct `Writer`.
Parameters
buf string- buffer
closed int- field (int)
nfiles int- field (int)
new_reader
pub fn new_reader(data &string) Reader
Purpose
Construct reader.
Parameters
data &string- data (borrowed; caller keeps it; type &string)
Returns
Reader — a value of this type
new_writer
pub fn new_writer() Writer
Purpose
Construct writer.
Parameters
none
Returns
Writer — a value of this type
(&Writer) file_count
pub fn (w &Writer) file_count() int
Purpose
Method on `&Writer`: file count.
Parameters
w &Writer- receiver &Writer (borrow)
Returns
int — a value of this type
(&mut Reader) next
pub fn (r &mut Reader) next() File
Purpose
Method on `&mut Reader`: take the next item, or end according to this type. Throws on failure.
Parameters
r &mut Reader- receiver &mut Reader (exclusive borrow)
Returns
File — a value of this type
(&Writer) bytes
pub fn (w &Writer) bytes() string
Purpose
Method on `&Writer`: return the buffered bytes.
Parameters
w &Writer- receiver &Writer (borrow)
Returns
string — result string
(&mut Writer) write_file
pub fn (w &mut Writer) write_file(name &string, body &string, mode int) int
Purpose
Method on `&mut Writer`: write file. Throws on failure.
Parameters
w &mut Writer- receiver &mut Writer (exclusive borrow)
name &string- name (borrowed; caller keeps it; type &string)
body &string- body (borrowed; caller keeps it; type &string)
mode int- mode (int)
Returns
int — a value of this type
(&mut Writer) write_dir
pub fn (w &mut Writer) write_dir(name &string, mode int) int
Purpose
Method on `&mut Writer`: write directory. Throws on failure.
Parameters
w &mut Writer- receiver &mut Writer (exclusive borrow)
name &string- name (borrowed; caller keeps it; type &string)
mode int- mode (int)
Returns
int — a value of this type
(&mut Writer) close
pub fn (w &mut Writer) close() int
Purpose
Method on `&mut Writer`: close the resource.
Parameters
w &mut Writer- receiver &mut Writer (exclusive borrow)
Returns
int — a value of this type