Author: wayland Date: 2009-08-20 07:12:22 +0200 (Thu, 20 Aug 2009) New Revision: 28040
Modified: docs/Perl6/Spec/S16-io.pod docs/Perl6/Spec/S32-setting-library/IO.pod Log: [S32/IO] and [S16] Changes include: * Removed spurious references to "Array of", now that pmichaud++ has explained things to me * Added a number of things to better cope with the Encoding * Other minor cleanups Modified: docs/Perl6/Spec/S16-io.pod =================================================================== --- docs/Perl6/Spec/S16-io.pod 2009-08-20 04:09:07 UTC (rev 28039) +++ docs/Perl6/Spec/S16-io.pod 2009-08-20 05:12:22 UTC (rev 28040) @@ -104,6 +104,9 @@ Any path that starts with a "/" is considered an absolute path, otherwise the path is considered relative. +When creating a path with p{}, the Path.Encoding attribute is set to $?ENC, unless +the :bin modifier (see below) is used. + =head3 Default constraints The default constraints can be set with the "use path" pragma, for example: @@ -167,7 +170,9 @@ =head3 :bin constraints (no constraints at all) If the above are causing problems, p:bin{} can be used as no checking is -done here, other than assuming that / is the separator. +done here. However, this leaves the Path.Encoding attribute undefined, which +means that certain features of Path will remain unavailable unless this +attribute is set. =head3 Other constraints Modified: docs/Perl6/Spec/S32-setting-library/IO.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/IO.pod 2009-08-20 04:09:07 UTC (rev 28039) +++ docs/Perl6/Spec/S32-setting-library/IO.pod 2009-08-20 05:12:22 UTC (rev 28040) @@ -528,7 +528,7 @@ =item shutdown - method shutdown(Array of Str @how) + method shutdown(Str @how) Does a I<shutdown(2)> on the connection. See also IO::Readable.isReadable and IO::Writeable.isWriteable. @@ -644,7 +644,7 @@ This represents the file systems mounted on the current machine (ie. accessible via a filesystem path). - class IO::FileSystem does IO::Streamable { + class IO::FileSystems { has Str $.illegal-chars; # ie. /\x0 has Int $.max-path; has Int $.max-path-element; @@ -662,15 +662,20 @@ If it succeeds it returns true, otherwise it returns C<Failure> and sets C<$!> (errno). Note, though, that chdir affects only the system directory; most things in Perl 6 that need a current directory depend -on their thread's copy of $*CWD. +on their thread's copy of $*CWD, so you probably want to set $*CWD +instead of using chdir(). =item find -Returns C<Path> objects. +Returns C<Path> objects. Path.Encoding is set to $?ENC unless the +$Encoding parameter is passed in (see Path for further discussion of +encoding). =item glob -Returns C<Path> objects. +Returns C<Path> objects. Path.Encoding is set to $?ENC unless the +Encoding parameter is passed in (see Path for further discussion of +encoding). =item rename @@ -684,9 +689,10 @@ role Path does Str does Array { has Str $.Type; + has Str @.Elements; has Str $.Encoding; - has Array of Buf @.Elements; - has Array of IO::ACL @.ACLs; + has Buf $.Binary; + has IO::ACL @.ACLs; has Hash of %.times; ... } @@ -694,14 +700,10 @@ C<$.Type> can be C<File>, C<Directory>, C<Link>, or C<Other>. See C<.create()> method documentation for how it is set. -$.Encoding tells us what the encoding is, if known. If $.Encoding is -undefined, then there are a number of things that can't be done with it, -such as treating is the Path as a Str, using say/print/any other display -method on it, and those kinds of things. +The C<@.Elements> array is a list of Str that contain the path elements, but +all are checked before being pushed onto the array. Note that @.Elements +can not be accessed unless $.Encoding is defined. -The <@.Elements> array is a list of Str that contain the path elements, but -all are checked before being pushed onto the array. - The C<%times> has keys that can be eg. C<ctime>, C<Modification>, and C<Access> (and maybe others on other operating systems), and the values are all C<Temporal::Instant> objects. @@ -721,23 +723,31 @@ This is called automatically on object creation. - method new( - Str :$Path, - Array of Str :@PathElements, + multi method new( + Str|Buf :$Path, + Str :@PathElements, + Str :$Encoding, - Array of Str :$Constraints, + Str :@Constraints, Str :$Protocol, Str :$Target, Str :$LinkType, + Str :$Type, ); Path and PathElements are mutually exclusive. +If the $Encoding parameter is not defined, then, if Path is a Buf, +the $.Encoding attribute remains undefined, otherwise it is set to +$?ENC. There are +a number of features that don't work without the encoding being set. + $Constraints determines whether the $Path and $Target strings should be assumed to be Unix-style, Windows-style, or something else. -The Path.Type attribute is initialised as follows: +If the Type option is not passed in, the Path.Type attribute is initialised +as follows: Value Condition ===== ========= @@ -746,7 +756,9 @@ Other $Protocol is specified Undefined All other cases -If the $.Type attribute is read, but is still undefined, then an attempt is +If the $.Type attribute is read (which will happen in a number of cases, +including when you read $.Target and $.LinkType), but is still undefined, +then an attempt is made to determine what its type should be from the filesystem. If no answers are found using this method, then it defaults to "File". @@ -791,7 +803,7 @@ =item resolvepath - method resolvepath(Array of Str @:Types --> Str); + method resolvepath(Str :@Types --> Str); @Types can contain "real" and "canon", in any order, and the method will run realpath and canonpath in the order specified.