Skip to content

Commit 2a7bd17

Browse files
committed
[io grant] Document IO::Spec::*.rel2abs
1 parent dcd7490 commit 2a7bd17

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

doc/Type/IO/Spec/Cygwin.pod6

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ Defined as:
106106
Same as L«C<IO::Spec::Win32.join>|/type/IO::Spec::Win32#method_join», except
107107
replaces backslashes with slashes in the final result.
108108
109+
=head2 method rel2abs
110+
111+
Defined as:
112+
113+
method rel2abs(|c --> List:D)
114+
115+
Same as L«C<IO::Spec::Win32.rel2abs>|/type/IO::Spec::Win32#method_rel2abs»,
116+
except replaces backslashes with slashes in the final result.
117+
109118
=head2 method split
110119
111120
Defined as:

doc/Type/IO/Spec/Unix.pod6

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,33 @@ an empty L<Seq> if C«%*ENV<PATH>» is not set or is an empty string.
208208
IO::Spec::Unix.path.perl.say;
209209
# OUTPUT: «("foo", "bar/ber", ".", "foo", ".").Seq␤»
210210
211+
=head2 method rel2abs
212+
213+
Defined as:
214+
215+
method rel2abs(Str() $path, $base = $*CWD --> Str:D)
216+
217+
Returns a string representing C<$path> converted to absolute path, based at
218+
C<$base>, which defaults to C<$*CWD>. If C<$base> is not an absolute path,
219+
it will be made absolute relative to C<$*CWD>, unless C<$*CWD> and C<$base>
220+
are the same.
221+
222+
=begin code
223+
say $*CWD; # OUTPUT: «"/home/camelia".IO␤»
224+
225+
say IO::Spec::Unix.rel2abs: 'foo'; # OUTPUT: «/home/camelia/foo␤»
226+
say IO::Spec::Unix.rel2abs: './'; # OUTPUT: «/home/camelia␤»
227+
say IO::Spec::Unix.rel2abs: 'foo/../../'; # OUTPUT: «/home/camelia/foo/../..␤»
228+
say IO::Spec::Unix.rel2abs: '/foo/'; # OUTPUT: «/foo␤»
229+
230+
say IO::Spec::Unix.rel2abs: 'foo', 'bar'; # OUTPUT: «/home/camelia/bar/foo␤»
231+
say IO::Spec::Unix.rel2abs: './', '/bar'; # OUTPUT: «/bar␤»
232+
say IO::Spec::Unix.rel2abs: '/foo/', 'bar'; # OUTPUT: «/foo␤»
233+
234+
say IO::Spec::Unix.rel2abs: 'foo/../../', 'bar';
235+
# OUTPUT: «/home/camelia/bar/foo/../..␤»
236+
=end code
237+
211238
=head2 method split
212239
213240
Defined as:

doc/Type/IO/Spec/Win32.pod6

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,33 @@ quotes (C<">) it finds.
180180
%*ENV<PATH> = 'foo;"bar"/"ber"';
181181
IO::Spec::Win32.path.perl.say; # OUTPUT: «(".", "foo", "bar/ber").Seq␤»
182182
183+
=head2 method rel2abs
184+
185+
Defined as:
186+
187+
method rel2abs(Str() $path, $base = $*CWD --> Str:D)
188+
189+
Returns a string representing C<$path> converted to absolute path, based at
190+
C<$base>, which defaults to C<$*CWD>. If C<$base> is not an absolute path,
191+
it will be made absolute relative to C<$*CWD>, unless C<$*CWD> and C<$base>
192+
are the same.
193+
194+
=begin code
195+
say $*CWD; # OUTPUT: «"C:\Users\camelia".IO␤»
196+
197+
say IO::Spec::Win32.rel2abs: 'foo'; # OUTPUT: «C:\Users\camelia\foo␤»
198+
say IO::Spec::Win32.rel2abs: './'; # OUTPUT: «C:\Users\camelia␤»
199+
say IO::Spec::Win32.rel2abs: 'foo/../../'; # OUTPUT: «C:\Users\camelia\foo\..\..␤»
200+
say IO::Spec::Win32.rel2abs: '/foo/'; # OUTPUT: «C:\foo␤»
201+
202+
say IO::Spec::Win32.rel2abs: 'foo', 'bar'; # OUTPUT: «C:\Users\camelia\bar\foo␤»
203+
say IO::Spec::Win32.rel2abs: './', '/bar'; # OUTPUT: «\bar␤»
204+
say IO::Spec::Win32.rel2abs: '/foo/', 'bar'; # OUTPUT: «C:\foo␤»
205+
206+
say IO::Spec::Win32.rel2abs: 'foo/../../', 'bar';
207+
# OUTPUT: «C:\Users\camelia\bar\foo\..\..␤»
208+
=end code
209+
183210
=head2 method split
184211
185212
Defined as:

0 commit comments

Comments
 (0)