comments: containers Chunks / MacFile / MpegEs / Ogg / IsoBmff (part) down to specs
This commit is contained in:
1 parent
9427e6e5fb
commit
e5a8e62fbc
8 files changed
+8
-92
No files matched your search
@@ -4,11 +4,6 @@
|
||||
-- the data fork is the entry `name`, a non-empty resource fork is a second entry `name .. ".rsrc"` with
|
||||
-- entry.fork = "resource"; both carry macType / macCreator (4-character strings), finderFlags, created / mtime (unix
|
||||
-- seconds) and comment. Writers pair them back with collect().
|
||||
--
|
||||
-- MacFile.put(archive, { name = "Read Me", data = buf, rsrc = buf2, type = "TEXT", creator = "ttxt" })
|
||||
-- local files, err = MacFile.collect(value, defaultName) -- { MacFile.Info } from any Archive / buffer / string
|
||||
-- MacFile.name(macRomanBytes) -> UTF-8 MacFile.roman(utf8) -> Mac OS Roman bytes
|
||||
-- MacFile.fromMac(secondsSince1904) -> unix seconds MacFile.toMac(unix) -> seconds since 1904 (u32, clamped)
|
||||
-- New code. Never throws.
|
||||
local Err = require("@rosetta/core/Err")
|
||||
local Archive = require("@rosetta/containers/Archive")
|
||||
@@ -56,7 +51,6 @@ for i, u in ROMAN do
|
||||
FROM_UNICODE[u] = 127 + i
|
||||
end
|
||||
|
||||
-- name(bytes) -> UTF-8 of a Mac OS Roman string (ASCII passes through)
|
||||
function MacFile.name(s: string): string
|
||||
if not string.find(s, "[\128-\255]") then
|
||||
return s
|
||||
@@ -69,7 +63,6 @@ function MacFile.name(s: string): string
|
||||
return table.concat(out)
|
||||
end
|
||||
|
||||
-- roman(utf8) -> Mac OS Roman bytes ("?" for characters it lacks; invalid UTF-8 passes through as bytes)
|
||||
function MacFile.roman(s: string): string
|
||||
if not string.find(s, "[\128-\255]") or not utf8.len(s) then
|
||||
return s
|
||||
@@ -88,8 +81,6 @@ local function four(s: any): string
|
||||
return string.sub(s .. "\0\0\0\0", 1, 4)
|
||||
end
|
||||
|
||||
-- put(archive, info, noData?): the data fork entry (unless noData: AppleDouble files carry none; or it is empty and
|
||||
-- there is a resource fork) and, when non-empty, the resource fork entry
|
||||
function MacFile.put(a: any, f: Info, noData: boolean?)
|
||||
local common = {
|
||||
macType = f.type,
|
||||
@@ -112,8 +103,6 @@ function MacFile.put(a: any, f: Info, noData: boolean?)
|
||||
end
|
||||
end
|
||||
|
||||
-- collect(value, name?) -> the Mac files of any Archive (resource fork entries joined to their data fork entry), a
|
||||
-- buffer or a string (one data fork named name, default "data")
|
||||
function MacFile.collect(value: any, name: string?): ({ Info }?, Err.Err?)
|
||||
local files, err = Archive.files(value, name)
|
||||
if not files then
|
||||
|
||||
Reference in new issue
Block a user