@@ -136,33 +136,11 @@ C<IO::Path>.
136
136
137
137
method child(IO::Path:D: Str() $childname --> IO::Path:D)
138
138
139
- Alias for L « C < .add > |/routine/add» . See also
140
- L « C < .child-secure > |/routine/child-secure»
141
-
142
- = head2 method child-secure
143
-
144
- method child-secure(IO::Path:D: Str() $childname --> IO::Path:D)
145
-
146
- Same as L « C < .child > |/routine/child» , except it will
147
- B « fully L < resolve|/routine/resolve > » the resultant path and check that it is in
148
- fact a child of the invocant. On success, returns the resultant path;
149
- L « fails|/routine/fail » with C < X::IO::Resolve > if the path could not be
150
- completely resolved or with C < X::IO::NotAChild > if the resultant path is not
151
- a child of the invocant.
152
-
153
- B < Note: > since the path has to be fully resolved, the method can still fail
154
- with C < X::IO::Resolve > even for paths that would be child paths, if some of
155
- the directories do not exist yet. The last part of the path does not have to
156
- exist for the routine to succeed.
157
-
158
- = for code :skip-test
159
- my $parent = 'foo'.IO.mkdir;
160
- say $parent.child-secure: 'bar'; # OUTPUT: «"foo/bar".IO»
161
- say $parent.child-secure: '../bar'; # Fails with X::IO::NotAChild
162
- say $parent.child-secure: 'bar/ber'; # Fails with X::IO::Resolve
163
-
164
- $parent.child('bar').mkdir; # create 'bar' so the call below succeeds
165
- say $parent.child-secure: 'bar/ber'; # OUTPUT: «"foo/bar/ber".IO»
139
+ Alias for L « C < .add > |/routine/add» . B < NOTE: > C < .child > will be switched to
140
+ secure version around 6.d release time, which will C < fail() > with non-child
141
+ paths and is also slower, since it has to do more work. Use
142
+ L « C < .add > |/routine/add» if your code does not need to guarantee the added
143
+ path is in fact a child path.
166
144
167
145
= head2 method extension
168
146
0 commit comments