Updated README to include libmtar documentation and added type annotations to libmtar
This commit is contained in:
parent
235684b979
commit
f7ee3e3250
@ -12,3 +12,12 @@ mtar archive files consist of a number of file entries, in the following format:
|
|||||||
- the file contents
|
- the file contents
|
||||||
|
|
||||||
Archives are terminated either by the end of file, or a record with a name length of zero.
|
Archives are terminated either by the end of file, or a record with a name length of zero.
|
||||||
|
|
||||||
|
## libmtar
|
||||||
|
|
||||||
|
libmtar is the reference implementation of mtar. It provides two functions:
|
||||||
|
|
||||||
|
- `libmtar.genHeader(string: name, number: len): string`
|
||||||
|
Generates an mtar file header for a file called *name* that is *len* bytes long.
|
||||||
|
- `libmtar.iter(table: stream): function`
|
||||||
|
Given buffer *stream*, returns an iterator suitable for use with *for* that returns, for each iteration, the file name, a function to read from the file, and the length of the file.
|
||||||
|
@ -19,7 +19,7 @@ local function cint(n,l)
|
|||||||
return string.reverse(string.char(table.unpack(t)):sub(1,l))
|
return string.reverse(string.char(table.unpack(t)):sub(1,l))
|
||||||
end
|
end
|
||||||
|
|
||||||
function mtar.genHeader(fname,len) -- generate a header for file *fname* when provided with file length *len*
|
function mtar.genHeader(fname,len) -- string number -- string -- Generates an mtar file header for a file called *name* that is *len* bytes long.
|
||||||
return string.format("%s%s%s",cint(fname:len(),2),fname,cint(len,2))
|
return string.format("%s%s%s",cint(fname:len(),2),fname,cint(len,2))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user