xref: /openbsd/usr.sbin/pkg_add/OpenBSD/Mtree.pod (revision f902ef06)
1$OpenBSD: Mtree.pod,v 1.2 2023/05/16 14:04:16 espie Exp $
2
3=head1 NAME
4
5OpenBSD::Mtree - simple C<mtree(8)> spec parser
6
7=head1 SYNOPSIS
8
9    use OpenBSD::Mtree;
10
11    my %hier;
12
13    OpenBSD::Mtree::parse(\%hier, "/", "/etc/mtree/4.4BSD.dist", $extra);
14
15=head1 DESCRIPTION
16
17C<OpenBSD::Mtree> is a parser for C<mtree(8)> specifications that
18can reconstruct directory hierarchies.
19
20The basic function C<OpenBSD::Mtree::parse_fh(\%hash, $basedir, $fh, $extra)>
21will populate the hash C<$hash> with defined entries for each directory
22seen while reading from C<$fh>, assuming the specification is to be interpreted
23relative to C<$basedir> (some canonicalization of directory names will
24occur).
25
26If C<$extra> is non null, each entry will itself be an empty hash.
27
28C<OpenBSD::Mtree:parse(\%hash, $basedir, $filename, $extra)> is a convenience
29function which also handles opening the filehandle from C<$filename>
30and closing it after reading the specification.
31