1Tree::Simple::Visitor::UCsreeratCeoDnitrreicbTturotereeyd:T:rPSeeierm(lp3l)Deo:c:uVmiesnittaotri:o:nCreateDirectoryTree(3)
2
3
4

NAME

6       Tree::Simple::Visitor::CreateDirectoryTree - A Visitor for create a set
7       of directories and files from a Tree::Simple object
8

SYNOPSIS

10         use Tree::Simple::Visitor::CreateDirectoryTree;
11
12         # create a Tree::Simple object which
13         # represents a directory hierarchy
14         my $tree = Tree::Simple->new("www/")
15                           ->addChildren(
16                               Tree::Simple->new("conf/")
17                                   ->addChildren(
18                                       Tree::Simple->new("startup.pl"),
19                                       Tree::Simple->new("httpd.conf")
20                                   ),
21                               Tree::Simple->new("cgi-bin/"),
22                               Tree::Simple->new("ht_docs/"),
23                               Tree::Simple->new("logs/")
24                                   ->addChildren(
25                                       Tree::Simple->new("error.log"),
26                                       Tree::Simple->new("access.log")
27                                   ),
28                           );
29
30         # create an instance of our visitor
31         my $visitor = Tree::Simple::Visitor::CreateDirectoryTree->new();
32
33         # pass the visitor to a Tree::Simple object
34         $tree->accept($visitor);
35
36         # the www/ directory now mirrors the structure of the tree
37

DESCRIPTION

39       This visitor can be used to create a set of directories and files from
40       a Tree::Simple object hierarchy.
41

METHODS

43       new There are no arguments to the constructor the object will be in its
44           default state. You can use the "setNodeFilter", "setFileHandler"
45           and "setDirectoryHandler" methods to customize its behavior.
46
47       setNodeFilter ($filter_function)
48           This method accepts a CODE reference as its $filter_function
49           argument and throws an exception if it is not a code reference.
50           This code reference is used to filter the tree nodes as they are
51           used to create the directory tree, it can be basically used as a
52           node pre-processor. An example usage of this might be to enforce
53           the 8.3 naming rules of DOS, or the 32 character limit of older
54           macintoshes.
55
56       setFileHandler ($file_handler)
57           This method accepts a CODE reference as its $file_handler argument
58           and throws an exception if it is not a CODE reference. This method
59           can be used to create custom file creation behavior.  The default
60           behavior is to just create the file and nothing else, but by using
61           this method it is possible to implement some other custom behavior,
62           such as creating a file based on a template.  The function is
63           passed the full path of the file to be created (as built by
64           File::Spec).
65
66       setDirectoryHandler ($dir_handler)
67           This method accepts a CODE reference as its $dir_handler argument
68           and throws an exception if it is not a CODE reference. This method
69           can be used to create custom directory creation behavior.  The
70           default behavior is to just create the directory and nothing else,
71           but by using this method it is possible to implement some other
72           custom behavior, such as creating a directory on a remote server.
73           The function is passed the full path of the directory to be created
74           (as built by File::Spec).
75
76       visit ($tree)
77           This is the method that is used by the Tree::Simple "accept"
78           method. It can also be used on its own, it requires the $tree
79           argument to be a Tree::Simple object (or derived from a
80           Tree::Simple object), and will throw and exception otherwise.
81
82           The tree is processed as follows:
83
84           Any node which is not a leaf is considered a directory.
85               Obviously since files themselves are leaf nodes, this makes
86               sense that non-leaves will be directories.
87
88           Any node (including leaf nodes) which ends in either the character
89           "/" or "\" is considered a directory.
90               I think it is a pretty standard convention to have directory
91               names ending in a separator. The separator itself is stripped
92               off before the directory name is passed to File::Spec where the
93               platform specific directory path is created. This means that it
94               does not matter which one you use, it will be completely cross
95               platform (at least as cross-platform as File::Spec is).
96
97           All other nodes are considered to be files.
98

Repository

100       <https://github.com/ronsavage/Tree-Simple-VisitorFactory>
101

SUPPORT

103       Bugs should be reported via the CPAN bug tracker at
104
105       <https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues>
106

CODE COVERAGE

108       See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more
109       information.
110

SEE ALSO

112       These Visitor classes are all subclasses of Tree::Simple::Visitor,
113       which can be found in the Tree::Simple module, you should refer to that
114       module for more information.
115

AUTHOR

117       stevan little, <stevan@iinteractive.com>
118
120       Copyright 2004, 2005 by Infinity Interactive, Inc.
121
122       <http://www.iinteractive.com>
123
124       This library is free software; you can redistribute it and/or modify it
125       under the same terms as Perl itself.
126
127
128
129perl v5.34.0                     T2r0e2e2:-:0S1i-m2p1le::Visitor::CreateDirectoryTree(3)
Impressum