@@ -17,13 +17,14 @@ DRAFT: Synopsis 32: Setting Library - IO
17
17
Tim Nelson <wayland@wayland.id.au>
18
18
Daniel Ruoso <daniel@ruoso.com>
19
19
Lyle Hopkins <webmaster@cosmicperl.com>
20
+ Brent Laabs <bslaabs@gmail.com>
20
21
21
22
=head1 VERSION
22
23
23
24
Created: 19 Feb 2009 extracted from S29-functions.pod; added stuff from S16-IO later
24
25
25
- Last Modified: 14 July 2012
26
- Version: 16
26
+ Last Modified: 28 March 2013
27
+ Version: 17
27
28
28
29
The document is a draft.
29
30
@@ -96,7 +97,9 @@ and the parent directory are excluded, which can be controlled with the
96
97
C<$test> named parameter. Only items that smart-match against this test are
97
98
returned.
98
99
99
- The return value is a list of C<IO::File> and C<IO::Dir> objects.
100
+ The return value is a list of C<IO::File> and C<IO::Dir> objects. Because of
101
+ this, you may want use the C<basename> method on the results to get the just
102
+ the file name, without its full path.
100
103
101
104
=item note
102
105
@@ -391,31 +394,30 @@ TODO: methods created, accessed, modified
391
394
class IO::Path is Cool does IO::FileTest { }
392
395
393
396
Holds a path of a file or directory. The path is generally divided
394
- into three parts, the I<file system >, I<directory> and I<base name>.
397
+ into three parts, the I<volume >, I<directory> and I<base name>.
395
398
396
- On Windows, the file system is a drive letter like C<C:>. Relative paths
397
- never have a file system part. On UNIX-based systems, the file system part
398
- is empty.
399
+ On Windows, the volume is a drive letter like C<C:>, or a UNC network volume
400
+ like C<\\share\>. On UNIX-based systems, the volume part is empty.
399
401
400
402
The base name is name of the file or directory that the IO::Path object
401
403
represents, and the directory is the part of the path leading up to the base
402
404
name.
403
405
404
- path file system directory base name
405
- /usr/bin/gvim /usr/bin gvim
406
- /usr/bin/ /usr bin
407
- C:\temp\f.txt C: temp f.txt
406
+ path volume directory base name
407
+ /usr/bin/gvim /usr/bin gvim
408
+ /usr/bin/ /usr bin
409
+ C:\temp\f.txt C: temp f.txt
408
410
409
411
=over 4
410
412
411
- =item path
413
+ =item Str
412
414
413
- Returns the path (file system , directory and base name joined together) as
414
- a string.
415
+ Stringification returns the path (volume , directory and base name joined
416
+ together) as a string.
415
417
416
- =item filesystem
418
+ =item volume
417
419
418
- Returns the file system part of the path
420
+ Returns the volume part of the path
419
421
420
422
=item directory
421
423
@@ -425,9 +427,50 @@ Returns the directory part of the path
425
427
426
428
Returns the base name part of the path
427
429
428
- =item Str
430
+ =item path
431
+
432
+ Returns the entire IO::Path object (a no-op).
433
+
434
+ =item contents
435
+
436
+ method contents( Mu :$test = none('.', '..') )
437
+
438
+ Returns a lazy list of file names in the path, if it is a directory. The
439
+ current and the parent directory are excluded, which can be controlled with
440
+ the C<$test> named parameter. Only items that smart-match against this test
441
+ are returned.
442
+
443
+ The return value is a list of C<IO::File> and C<IO::Dir> objects. Because of
444
+ this, you may want use the C<basename> method on the results to get the just
445
+ the file name, without its full path.
446
+
447
+ =item is-relative
448
+
449
+ Returns True if the path is a relative path (like C<foo/bar>), False
450
+ otherwise.
451
+
452
+ =item is-absolute
453
+
454
+ Returns True if the path is an absolute path (like C</usr/bin>), False
455
+ otherwise.
456
+
457
+ =item absolute
458
+
459
+ method absolute ( Str $base = $*CWD )
460
+
461
+ Transforms the path into an absolute form, and returns the result as a new
462
+ IO::Path. If C<$base> is supplied, transforms it relative to that base
463
+ directory; otherwise the current working directory is used. Paths that are
464
+ already absolute are returned unchanged.
465
+
466
+ =item relative
467
+
468
+ method relative ( Str $base = $*CWD )
429
469
430
- Stringifies to the base name.
470
+ Transforms the path into an relative form, and returns the result as a new
471
+ IO::Path. If C<$base> is supplied, transforms it relative to that base
472
+ directory; otherwise the current working directory is used. Paths that are
473
+ already relative are returned unchanged.
431
474
432
475
=back
433
476
0 commit comments