~sircmpwn/hare-tar

d1120d07247e91b80253bccf2b30f0013e5d2d60 — Armin Preiml 1 year, 1 month ago 012b291
use SZ as suffix for sizes in other modules

Signed-off-by: Armin Preiml <apreiml@strohwolke.at>
2 files changed, 8 insertions(+), 8 deletions(-)

M reader.ha
M types.ha
M reader.ha => reader.ha +6 -6
@@ 31,7 31,7 @@ export fn read(src: io::handle) reader = {
//
// Note that reading from the header will modify the file size.
export fn next(rd: *reader) (entry | error | io::EOF) = {
	static let buf: [BLOCKSIZE]u8 = [0...];
	static let buf: [BLOCKSZ]u8 = [0...];
	match (io::read(rd.src, buf)?) {
	case let z: size =>
		if (z != len(buf)) {


@@ 107,8 107,8 @@ export fn next(rd: *reader) (entry | error | io::EOF) = {
// Seeks the underlying tar file to the entry following this one.
export fn skip(ent: *entry) (void | io::error) = {
	let amt = ent.remain;
	if (amt % BLOCKSIZE != 0) {
		amt += BLOCKSIZE - (amt % BLOCKSIZE);
	if (amt % BLOCKSZ != 0) {
		amt += BLOCKSZ - (amt % BLOCKSZ);
	};
	match (io::seek(ent.src, amt: io::off, io::whence::CUR)) {
	case io::off =>


@@ 148,9 148,9 @@ fn file_read(s: *io::stream, buf: []u8) (size | io::EOF | io::error) = {
	ent.remain -= z;

	// Read until we reach the block size
	static let buf: [BLOCKSIZE]u8 = [0...];
	if (ent.remain == 0 && ent.orig % BLOCKSIZE != 0) {
		let remain = BLOCKSIZE - (ent.orig % BLOCKSIZE);
	static let buf: [BLOCKSZ]u8 = [0...];
	if (ent.remain == 0 && ent.orig % BLOCKSZ != 0) {
		let remain = BLOCKSZ - (ent.orig % BLOCKSZ);
		for (remain > 0) {
			match (io::read(ent.src, buf[..remain])?) {
			case let z: size =>

M types.ha => types.ha +2 -2
@@ 3,7 3,7 @@
use io;

// The size of each block in a tar file.
export def BLOCKSIZE: size = 512;
export def BLOCKSZ: size = 512;

// A file or directory in a tar file.
export type entry = struct {


@@ 43,7 43,7 @@ export type entry_type = enum u8 {
	FIFO,
};

// Returned if the source file size is not aligned on [[BLOCKSIZE]].
// Returned if the source file size is not aligned on [[BLOCKSZ]].
export type truncated = !void;

// Returned if the source file does not contain a valid ustar archive.