=encoding euc-jp =head1 NAME =begin original URI::file - URI that maps to local file names =end original URI::file - ローカル・ファイル名に対応する URI =head1 SYNOPSIS use URI::file; $u1 = URI->new("file:/foo/bar"); $u2 = URI->new("foo/bar", "file"); $u3 = URI::file->new($path); $u4 = URI::file->new("c:\\windows\\", "win32"); $u1->file; $u1->file("mac"); =head1 DESCRIPTION =begin original The C class supports C objects belonging to the I URI scheme. This scheme allows us to map the conventional file names found on various computer systems to the URI name space. An old specification of the I URI scheme is found in RFC 1738. Some older background information is also in RFC 1630. There are no newer specifications as far as I know. =end original C クラスは I URI スキームに所属する C オブジェクトを サポートします。 このスキームはさまざまなコンピュータシステム上で見つかった従来のファイル名を、 URI 名前空間に対応づけることを可能にします。 I スキームの古い仕様は RFC 1738 にあります。 いくつかのより古い背景情報は RFC 1630 にもあります。 私が知る限り、より新しい仕様はありません。 =begin original If you simply want to construct I URI objects from URI strings, use the normal C constructor. If you want to construct I URI objects from the actual file names used by various systems, then use one of the following C constructors: =end original URI 文字列から I URI オブジェクトを単純に組み立てたいのであれば、 通常の C コンストラクタを使ってください。 さまざまなシステムによって使われる実際のファイル名から I URI オブジェクトを組み立てたいならば、以下の C コンスタラクタの 一つを使ってください。 =over 4 =item $u = URI::file->new( $filename, [$os] ) =begin original Maps a file name to the I URI name space, creates a URI object and returns it. The $filename is interpreted as belonging to the indicated operating system ($os), which defaults to the value of the $^O variable. The $filename can be either absolute or relative, and the corresponding type of URI object for $os is returned. =end original ファイル名を I URI名前空間に対応づけ、URI オブジェクトを作成し、 それを返します。 $filename は指定されたオペレーティングシステム($os)に所属するものとして 解釈されます。 (オペレーティングシステムの)デフォルトは $^O 変数の値になります。 $filename は絶対でも相対でも指定することができ、$os のための URI オブジェクトの 対応するタイプが返されます。 =item $u = URI::file->new_abs( $filename, [$os] ) =begin original Same as URI::file->new, but makes sure that the URI returned represents an absolute file name. If the $filename argument is relative, then the name is resolved relative to the current directory, i.e. this constructor is really the same as: =end original URI::file->new と同じですが、返される URI は絶対ファイル名であることを 保証します。 $filename 引数が相対であれば、名前は現在のディレクトリからの相対として 解決されます。 つまりこのコンストラクタは以下のものと実質的に同じです: URI::file->new($filename)->abs(URI::file->cwd); =item $u = URI::file->cwd =begin original Returns a I URI that represents the current working directory. See L. =end original 現在の作業ディレクトリを表す I URI を返します。 L を参照してください。 =back =begin original The following methods are supported for I URI (in addition to the common and generic methods described in L): =end original 以下のメソッドは (URIで記述されている共通と汎用メソッドに加えて) I URI のためにサポートされています: =over 4 =item $u->file( [$os] ) =begin original Returns a file name. It maps from the URI name space to the file name space of the indicated operating system. =end original ファイル名を返します。 URI 名前空間から指定されたオペレーティングシステムのファイル名空間に 対応づけます。 =begin original It might return C if the name can not be represented in the indicated file system. =end original 指定されたファイルシステムでは表現することができなければ、 C を返すかもしれません。 =item $u->dir( [$os] ) =begin original Some systems use a different form for names of directories than for plain files. Use this method if you know you want to use the name for a directory. =end original システムによってはディレクトリ名にプレーンなファイルとは違う形式を 使うものもあります。 ディレクトリに使いたい名前が分かっていれば、このメソッドを使ってください。 =back =begin original The C module can be used to map generic file names to names suitable for the current system. As such, it can work as a nice replacement for the C module. For instance, the following code translates the UNIX-style file name F to a name suitable for the local system: =end original C モジュールは汎用のファイル名を現在のシステムにあった名前に 対応づけるために使うことができます。 そのような場合、C モジュールの代わりとして動くことができます。 例えば以下のコードは Unix 形式のファイル名 F をローカルシステムに あった名前に変換します: $file = URI::file->new("Foo/Bar.pm", "unix")->file; die "Can't map filename Foo/Bar.pm for $^O" unless defined $file; open(FILE, $file) || die "Can't open '$file': $!"; # do something with FILE =head1 MAPPING NOTES (マッピングの注意) =begin original Most computer systems today have hierarchically organized file systems. Mapping the names used in these systems to the generic URI syntax allows us to work with relative file URIs that behave as they should when resolved using the generic algorithm for URIs (specified in RFC 2396). Mapping a file name to the generic URI syntax involves mapping the path separator character to "/" and encoding any reserved characters that appear in the path segments of the file name. If path segments consisting of the strings "." or ".." have a different meaning than what is specified for generic URIs, then these must be encoded as well. =end original 今日のほとんどのコンピュータシステムは階層的に組織されたファイルシステムを 持っています。 これらのシステムから汎用 URI 書式で使われる対応づけは、(RFC 2396 で 定義されている)URI のための汎用アルゴリズムを使って解決されるとき、 そうするべきであるように振る舞う相対ファイル URI と一緒に作業することを 可能にします。 ファイル名から汎用 URI 書式への対応づけはパス区切り文字を "/" に 対応づけること、ファイル名のパスセグメントにあらわれる予約された文字の すべてをエンコーディングすることを含みます。 "." や ".." が入っているパスセグメントが汎用 URI に指定されているものとは 違う意味を持っていれば、これらもエンコードされなければなりません。 =begin original If the file system has device, volume or drive specifications as the root of the name space, then it makes sense to map them to the authority field of the generic URI syntax. This makes sure that relative URIs can not be resolved "above" them, i.e. generally how relative file names work in those systems. =end original ファイルシステムがデバイス、ボリュームまたはドライブ指定を名前空間の ルートとして持っていれば、汎用 URI 書式の authority フィールドへ それらが対応づけることを意味します。 相対 URI は、これにより「上に」解決されないことはないこと、つまり一般的に 相対ファイル名はそれらのシステムで機能することを保証します。 =begin original Another common use of the authority field is to encode the host on which this file name is valid. The host name "localhost" is special and generally has the same meaning as a missing or empty authority field. This use is in conflict with using it as a device specification, but can often be resolved for device specifications having characters not legal in plain host names. =end original もう一つの authority フィ−ルドの一般的な使い方は、このファイル名が 適正であるホストをエンコードすることです。 ホスト名 "localhost" は特別で、一般的に authority フィールドがないか、 空であるのと同じ意味を持ちます。 この使い方はデバイスの指定として使うこととぶつかりますが、デバイス名が プレーンなホスト名では正しくない文字を持っていることにより 解決されることが多くあります。 =begin original File name to URI mapping in normally not one-to-one. There are usually many URIs that map to any given file name. For instance, an authority of "localhost" maps the same as a URI with a missing or empty authority. =end original ファイル名から URI へのマッピングは通常 1 対 1 ではありません。 通常たくさんの URI が同じファイル名に対応づけられます。 例えば、"localhost" の authority は authority がなかったり、空だったりする URI と同じように対応づけられます。 =begin original Example 1: The Mac uses ":" as path separator, but not in the same way as a generic URI. ":foo" is a relative name. "foo:bar" is an absolute name. Also, path segments can contain the "/" character as well as the literal "." or "..". So the mapping looks like this: =end original 例1: Macは ":" を区切り文字として使いますが、一般的な URI とは 同じ方法ではありません。 ":foo" は相対名です。 "foo:bar" は絶対名です。 またパスセグメントには "/", ".", ".." を入れることができます。 それでマッピングは以下のようになります: Mac URI ---------- ------------------- :foo:bar <==> foo/bar : <==> ./ ::foo:bar <==> ../foo/bar ::: <==> ../../ foo:bar <==> file:/foo/bar foo:bar: <==> file:/foo/bar/ .. <==> %2E%2E <== / foo/ <== file:/foo%2F ./foo.txt <== file:/.%2Ffoo.txt =begin original Note that if you want a relative URL, you *must* begin the path with a :. Any path that begins with [^:] is treated as absolute. =end original 注意: もし相対 URL が欲しければ、パスは : から始めなければ*いけません*。 [^:](: 以外)から始まるパスは絶対として扱われます。 =begin original Example 2: The UNIX file system is easy to map, as it uses the same path separator as URIs, has a single root, and segments of "." and ".." have the same meaning. URIs that have the character "\0" or "/" as part of any path segment can not be turned into valid UNIX file names. =end original 例2: Unix ファイルシステムは URI と同じパス区切り文字を使っていて、 一つのルートを持ち、"." と ".." のセグメントが同じ意味を持つので、 対応付けが簡単です。 文字 "\0" や "/" をパスセグメントの一部として持っている URI は正しい Unix ファイル名にすることはできません。 UNIX URI ---------- ------------------ foo/bar <==> foo/bar /foo/bar <==> file:/foo/bar /foo/bar <== file://localhost/foo/bar file: ==> ./file: <== file:/fo%00/bar / <==> file:/ =cut =head1 CONFIGURATION VARIABLES (設定変数) =begin original The following configuration variables influence how the class and its methods behave: =end original 次の設定変数は、クラスとそのメソッドがどのように振る舞うかに 影響を与えます: =over =item %URI::file::OS_CLASS =begin original This hash maps OS identifiers to implementation classes. You might want to add or modify this if you want to plug in your own file handler class. Normally the keys should match the $^O values in use. =end original このハッシュは、実装クラスの OS 識別子をマッピングします。 You might want to add or modify this if you want to plug in your own file handler class. Normally the keys should match the $^O values in use. (TBT) =begin original If there is no mapping then the "Unix" implementation is used. =end original マッピングがない場合、"Unix" が使われます。 =item $URI::file::DEFAULT_AUTHORITY =begin original This determine what "authority" string to include in absolute file URIs. It defaults to "". If you prefer verbose URIs you might set it to be "localhost". =end original This determine what "authority" string to include in absolute file URIs. デフォルトは "" です。 詳細な URI を好む場合、"localhost" に設定する方がよいでしょう。 (TBT) =begin original Setting this value to C force behaviour compatible to URI v1.31 and earlier. In this mode host names in UNC paths and drive letters are mapped to the authority component on Windows, while we produce authority-less URIs on Unix. =end original Setting this value to C force behaviour compatible to URI v1.31 and earlier. In this mode host names in UNC paths and drive letters are mapped to the authority component on Windows, while we produce authority-less URIs on Unix. (TBT) =back =head1 SEE ALSO L, L, L =head1 COPYRIGHT Copyright 1995-1998,2004 Gisle Aas. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =begin meta Translate: Hippo2000 (1.04) Update: SHIRAKATA Kentaro (1.35) Status: in progress =end meta =cut