Class Overview
- class c64os_util.car.record.ArchiveRecord
ArchiveRecordis the base class for all records (files and directories) within the archive.ArchiveRecordis abstract and cannot be instantiated; instead, an instance of one of the derived classes (ArchiveFileorArchiveDirectory) should be created.- property compression_type: CarCompressionType
Get the record compression type.
- Returns:
The record compression type.
- static deserialize(buffer: BinaryIO) ArchiveRecord
Read binary data from a buffer and parse it into a record object.
- Parameters:
buffer – The buffer from which to read.
- Returns:
The parsed record object.
- property header: ArchiveRecordHeader
Get this record’s header.
- Returns:
The record header.
- property name: str
Get the record name.
- Returns:
The record name.
- property record_type: CarRecordType
Get the record type (file or directory).
- Returns:
The record type.
- serialize(buffer: BinaryIO)
Convert this record into binary data and write it to a buffer.
- Parameters:
buffer – The buffer into which to write.
- property size: int
Get the record size.
- Returns:
The record size.
- class c64os_util.car.record.ArchiveDirectory(name: str = '', iterable: list[c64os_util.car.record.record.ArchiveRecord] | None = None)
ArchiveDirectory is used to represent directories within a C64 archive. As in a filesystem, archive directories can contain files or other (nested) directories. In an archive, a directory cannot have more than one entry with the same name (names must be unique among children) – even if one of those entries is a directory and the other is a file.
ArchiveDirectory is a list; children can be directly inserted or removed.instance Inserting a new child can raise a ValueError if the directory already has a child of the same name.
ArchiveDirectory also support dict-style indexing to look up children by name. This syntax only supports read operations.
Example:
d = ArchiveDirectory(name='test') d.append(ArchiveDirectory(name='nested')) d += [ ArchiveFile(name='foo'), ArchiveFile(name='bar') ] for record in d: print(record.name) print(d['foo'].file_type) print(d['bar'].file_type)
- append(item)
Append the given record as a child of this directory.
- property compression_type: CarCompressionType
Get the record compression type. (Always NONE for directories.)
- Returns:
The record compression type.
- directories()
A generator which iterates through all directories that are direct children of this one.
- extend(other)
Append all the items in the given list as children of this directory.
- files()
A generator which iterates through all files that are direct children of this directory.
- get_child(name: str) ArchiveRecord | None
Get a child record by name.
- Returns:
The child record, or None if no children exist by that name.
- insert(index, item)
Insert the given record as a child of this directory at the given index.
- items() List[Tuple[str, ArchiveRecord]]
Get a list of key-value pairs for all records in this directory. The key is the record name, and the value is the record itself.
- Returns:
List of key-value pairs.
- keys()
Get a list of the names of all records in this directory.
- Returns:
List of record names.
- merge(other: ArchiveDirectory)
Merge the contents of another directory into this directory.
- Parameters:
other – The other directory.
- property record_type: CarRecordType
Get the record type for directories.
- Returns:
The record type (DIRECTORY).
- serialize(buffer: BinaryIO)
Convert this record into binary data and write it to a buffer.
- Parameters:
buffer – The buffer into which to write.
- property size: int
Get the record size. (Number of children.)
- Returns:
The record size.
- values()
Get a list of all records in this directory.
- Returns:
List of records.
- class c64os_util.car.record.ArchiveFile(name: str = '', file_type: CarRecordType = CarRecordType.SEQFILE, compression_type: CarCompressionType = CarCompressionType.NONE)
An
ArchiveFilerepresents a single file within the archive.- property compression_type: CarCompressionType
Get the file compression type. (Only NONE is supported.)
- Returns:
The file compression type.
- property file_type: CarRecordType
Get the file type (SEQ or PRG).
- Returns:
The file type.
- property record_type
Get the file type (SEQ or PRG).
- Returns:
The file type.
- serialize(buffer: BinaryIO)
Convert this record into binary data and write it to a buffer.
- Parameters:
buffer – The buffer into which to write.
- property size: int
Get the record size. (Size of file in bytes.)
- Returns:
The record size.