Skip to main content

Module fork_export

Module fork_export 

Source
Expand description

Fork-preserving single-file export, shared by the browse view’s “Extract” and Commander’s copy/export-to-host.

Reads a file’s data fork (read_file) and resource fork (write_resource_fork_to) off any Filesystem and writes it into a host directory in the chosen ResourceForkMode:

  • MacBinary — single .bin carrying both forks (only when a resource fork is present; otherwise falls through to a plain data-fork write).
  • BinHex — single .hqx text file (always applicable; carries Finder info even with no resource fork).
  • AppleDouble — data fork under the plain name + a ._name sidecar (emitted whenever there’s a resource fork or type/creator to preserve).
  • Native — data fork + the macOS ..namedfork/rsrc write (macOS only).
  • SeparateRsrc — data fork + a name.rsrc sidecar.
  • DataForkOnly — just the data fork.

This mirrors the browse view’s extract_entry per-file logic in one place so Commander gets identical output, and it works over the remote wire too (RemoteFilesystem implements write_resource_fork_to via the daemon’s resource-fork read op).

Structs§

ForkExportOptions
Choices export_file_with_fork_opts adds to export_file_with_fork.

Functions§

export_file_with_fork
Export one FILE entry into dest_dir under the base name out_name (already sanitized / suffixed by the caller — e.g. the browse view appends a ProDOS #TTAAAA suffix), using mode. Returns the number of bytes written (data + resource) for progress accounting. The caller handles directories (create + recurse). Use safe_name for the default sanitized name.
export_file_with_fork_opts
export_file_with_fork with its ForkExportOptions spelled out.
primary_output_path
The host path export_file_with_fork writes entry’s data to under mode, so a caller can see a collision before anything is overwritten.
safe_name
The default sanitized host filename for entry (no ProDOS type suffix). Callers with no special naming needs pass this as out_name.