Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / URI::file.3pm
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  | will give a
29 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
32 .tr \(*W-|\(bv\*(Tr
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "URI::file 3"
132 .TH URI::file 3 "2009-05-28" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 URI::file \- URI that maps to local file names
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 .Vb 1
138 \& use URI::file;
139 .Ve
140 .PP
141 .Vb 2
142 \& $u1 = URI\->new("file:/foo/bar");
143 \& $u2 = URI\->new("foo/bar", "file");
144 .Ve
145 .PP
146 .Vb 2
147 \& $u3 = URI::file\->new($path);
148 \& $u4 = URI::file\->new("c:\e\ewindows\e\e", "win32");
149 .Ve
150 .PP
151 .Vb 2
152 \& $u1\->file;
153 \& $u1\->file("mac");
154 .Ve
155 .SH "DESCRIPTION"
156 .IX Header "DESCRIPTION"
157 The \f(CW\*(C`URI::file\*(C'\fR class supports \f(CW\*(C`URI\*(C'\fR objects belonging to the \fIfile\fR
158 \&\s-1URI\s0 scheme.  This scheme allows us to map the conventional file names
159 found on various computer systems to the \s-1URI\s0 name space.  An old
160 specification of the \fIfile\fR \s-1URI\s0 scheme is found in \s-1RFC\s0 1738.  Some
161 older background information is also in \s-1RFC\s0 1630. There are no newer
162 specifications as far as I know.
163 .PP
164 If you simply want to construct \fIfile\fR \s-1URI\s0 objects from \s-1URI\s0 strings,
165 use the normal \f(CW\*(C`URI\*(C'\fR constructor.  If you want to construct \fIfile\fR
166 \&\s-1URI\s0 objects from the actual file names used by various systems, then
167 use one of the following \f(CW\*(C`URI::file\*(C'\fR constructors:
168 .ie n .IP "$u = URI::file\->new( $filename, [$os] )" 4
169 .el .IP "$u = URI::file\->new( \f(CW$filename\fR, [$os] )" 4
170 .IX Item "$u = URI::file->new( $filename, [$os] )"
171 Maps a file name to the \fIfile:\fR \s-1URI\s0 name space, creates a \s-1URI\s0 object
172 and returns it.  The \f(CW$filename\fR is interpreted as belonging to the
173 indicated operating system ($os), which defaults to the value of the
174 $^O variable.  The \f(CW$filename\fR can be either absolute or relative, and
175 the corresponding type of \s-1URI\s0 object for \f(CW$os\fR is returned.
176 .ie n .IP "$u = URI::file\->new_abs( $filename, [$os] )" 4
177 .el .IP "$u = URI::file\->new_abs( \f(CW$filename\fR, [$os] )" 4
178 .IX Item "$u = URI::file->new_abs( $filename, [$os] )"
179 Same as URI::file\->new, but makes sure that the \s-1URI\s0 returned
180 represents an absolute file name.  If the \f(CW$filename\fR argument is
181 relative, then the name is resolved relative to the current directory,
182 i.e. this constructor is really the same as:
183 .Sp
184 .Vb 1
185 \&  URI::file\->new($filename)\->abs(URI::file\->cwd);
186 .Ve
187 .IP "$u = URI::file\->cwd" 4
188 .IX Item "$u = URI::file->cwd"
189 Returns a \fIfile\fR \s-1URI\s0 that represents the current working directory.
190 See Cwd.
191 .PP
192 The following methods are supported for \fIfile\fR \s-1URI\s0 (in addition to
193 the common and generic methods described in \s-1URI\s0):
194 .IP "$u\->file( [$os] )" 4
195 .IX Item "$u->file( [$os] )"
196 Returns a file name.  It maps from the \s-1URI\s0 name space
197 to the file name space of the indicated operating system.
198 .Sp
199 It might return \f(CW\*(C`undef\*(C'\fR if the name can not be represented in the
200 indicated file system.
201 .IP "$u\->dir( [$os] )" 4
202 .IX Item "$u->dir( [$os] )"
203 Some systems use a different form for names of directories than for plain
204 files.  Use this method if you know you want to use the name for
205 a directory.
206 .PP
207 The \f(CW\*(C`URI::file\*(C'\fR module can be used to map generic file names to names
208 suitable for the current system.  As such, it can work as a nice
209 replacement for the \f(CW\*(C`File::Spec\*(C'\fR module.  For instance, the following
210 code translates the UNIX-style file name \fIFoo/Bar.pm\fR to a name
211 suitable for the local system:
212 .PP
213 .Vb 4
214 \&  $file = URI::file\->new("Foo/Bar.pm", "unix")\->file;
215 \&  die "Can't map filename Foo/Bar.pm for $^O" unless defined $file;
216 \&  open(FILE, $file) || die "Can't open '$file': $!";
217 \&  # do something with FILE
218 .Ve
219 .SH "MAPPING NOTES"
220 .IX Header "MAPPING NOTES"
221 Most computer systems today have hierarchically organized file systems.
222 Mapping the names used in these systems to the generic \s-1URI\s0 syntax
223 allows us to work with relative file URIs that behave as they should
224 when resolved using the generic algorithm for URIs (specified in \s-1RFC\s0
225 2396).  Mapping a file name to the generic \s-1URI\s0 syntax involves mapping
226 the path separator character to \*(L"/\*(R" and encoding any reserved
227 characters that appear in the path segments of the file name.  If
228 path segments consisting of the strings \*(L".\*(R" or \*(L"..\*(R" have a
229 different meaning than what is specified for generic URIs, then these
230 must be encoded as well.
231 .PP
232 If the file system has device, volume or drive specifications as
233 the root of the name space, then it makes sense to map them to the
234 authority field of the generic \s-1URI\s0 syntax.  This makes sure that
235 relative URIs can not be resolved \*(L"above\*(R" them, i.e. generally how
236 relative file names work in those systems.
237 .PP
238 Another common use of the authority field is to encode the host on which
239 this file name is valid.  The host name \*(L"localhost\*(R" is special and
240 generally has the same meaning as a missing or empty authority
241 field.  This use is in conflict with using it as a device
242 specification, but can often be resolved for device specifications
243 having characters not legal in plain host names.
244 .PP
245 File name to \s-1URI\s0 mapping in normally not one\-to\-one.  There are
246 usually many URIs that map to any given file name.  For instance, an
247 authority of \*(L"localhost\*(R" maps the same as a \s-1URI\s0 with a missing or empty
248 authority.
249 .PP
250 Example 1: The Mac uses \*(L":\*(R" as path separator, but not in the same way
251 as a generic \s-1URI\s0. \*(L":foo\*(R" is a relative name.  \*(L"foo:bar\*(R" is an absolute
252 name.  Also, path segments can contain the \*(L"/\*(R" character as well as the
253 literal \*(L".\*(R" or \*(L"..\*(R".  So the mapping looks like this:
254 .PP
255 .Vb 12
256 \&  Mac                   URI
257 \&  \-\-\-\-\-\-\-\-\-\-            \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
258 \&  :foo:bar     <==>     foo/bar
259 \&  :            <==>     ./
260 \&  ::foo:bar    <==>     ../foo/bar
261 \&  :::          <==>     ../../
262 \&  foo:bar      <==>     file:/foo/bar
263 \&  foo:bar:     <==>     file:/foo/bar/
264 \&  ..           <==>     %2E%2E
265 \&  <undef>      <==      /
266 \&  foo/         <==      file:/foo%2F
267 \&  ./foo.txt    <==      file:/.%2Ffoo.txt
268 .Ve
269 .PP
270 Note that if you want a relative \s-1URL\s0, you *must* begin the path with a :.  Any
271 path that begins with [^:] is treated as absolute.
272 .PP
273 Example 2: The \s-1UNIX\s0 file system is easy to map, as it uses the same path
274 separator as URIs, has a single root, and segments of \*(L".\*(R" and \*(L"..\*(R"
275 have the same meaning.  URIs that have the character \*(L"\e0\*(R" or \*(L"/\*(R" as
276 part of any path segment can not be turned into valid \s-1UNIX\s0 file names.
277 .PP
278 .Vb 8
279 \&  UNIX                  URI
280 \&  \-\-\-\-\-\-\-\-\-\-            \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
281 \&  foo/bar      <==>     foo/bar
282 \&  /foo/bar     <==>     file:/foo/bar
283 \&  /foo/bar     <==      file://localhost/foo/bar
284 \&  file:         ==>     ./file:
285 \&  <undef>      <==      file:/fo%00/bar
286 \&  /            <==>     file:/
287 .Ve
288 .SH "CONFIGURATION VARIABLES"
289 .IX Header "CONFIGURATION VARIABLES"
290 The following configuration variables influence how the class and its
291 methods behave:
292 .IP "%URI::file::OS_CLASS" 4
293 .IX Item "%URI::file::OS_CLASS"
294 This hash maps \s-1OS\s0 identifiers to implementation classes.  You might
295 want to add or modify this if you want to plug in your own file
296 handler class.  Normally the keys should match the $^O values in use.
297 .Sp
298 If there is no mapping then the \*(L"Unix\*(R" implementation is used.
299 .IP "$URI::file::DEFAULT_AUTHORITY" 4
300 .IX Item "$URI::file::DEFAULT_AUTHORITY"
301 This determine what \*(L"authority\*(R" string to include in absolute file
302 URIs.  It defaults to "\*(L".  If you prefer verbose URIs you might set it
303 to be \*(R"localhost".
304 .Sp
305 Setting this value to \f(CW\*(C`undef\*(C'\fR force behaviour compatible to \s-1URI\s0 v1.31
306 and earlier.  In this mode host names in \s-1UNC\s0 paths and drive letters
307 are mapped to the authority component on Windows, while we produce
308 authority-less URIs on Unix.
309 .SH "SEE ALSO"
310 .IX Header "SEE ALSO"
311 \&\s-1URI\s0, File::Spec, perlport
312 .SH "COPYRIGHT"
313 .IX Header "COPYRIGHT"
314 Copyright 1995\-1998,2004 Gisle Aas.
315 .PP
316 This library is free software; you can redistribute it and/or
317 modify it under the same terms as Perl itself.