-
Notifications
You must be signed in to change notification settings - Fork 0
/
chap-19.texi
2551 lines (1869 loc) · 86.6 KB
/
chap-19.texi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@node Filenames
@chapter Filenames
@menu
* Overview of Filenames::
* Pathnames::
* Logical Pathnames::
* Filenames Dictionary::
@end menu
@node Overview of Filenames
@section Overview of Filenames
There are many kinds of @term{file systems},
varying widely both in their superficial syntactic details,
and in their underlying power and structure.
The facilities provided by @clisp{}@spc{}for referring to and manipulating @term{files}
has been chosen to be compatible with many kinds of @term{file systems},
while at the same time minimizing the program-visible differences
between kinds of @term{file systems}.
Since @term{file systems} vary in their conventions for naming @term{files},
there are two distinct ways to represent @term{filenames}:
as @term{namestrings} and as @term{pathnames}.
@menu
* Namestrings as Filenames::
* Pathnames as Filenames::
* Parsing Namestrings Into Pathnames::
@end menu
@node Namestrings as Filenames
@subsection Namestrings as Filenames
A @newterm{namestring} is a @term{string} that represents a @term{filename}.
In general, the syntax of @term{namestrings} involves the use of
@term{implementation-defined} conventions,
usually those customary for the @term{file system} in which the named @term{file} resides.
The only exception is the syntax of a @term{logical pathname} @term{namestring},
which is defined in this specification; see @ref{Syntax of Logical Pathname Namestrings}.
A @term{conforming program} must never unconditionally use a
@term{literal} @term{namestring} other than a @term{logical pathname} @term{namestring}
because @clisp{}@spc{}does not define any @term{namestring} syntax
other than that for @term{logical pathnames}
that would be guaranteed to be portable.
However, a @term{conforming program} can, if it is careful,
successfully manipulate user-supplied data
which contains or refers to non-portable @term{namestrings}.
A @term{namestring} can be @term{coerced} to a @term{pathname} by @thefunctions{pathname}
or @symbolref{parse-namestring, SYM}.
@node Pathnames as Filenames
@subsection Pathnames as Filenames
@cindex pathname
@dfn{Pathnames} are structured @term{objects} that can represent,
in an @term{implementation-independent} way,
the @term{filenames} that are used natively by an underlying @term{file system}.
In addition, @term{pathnames} can also represent certain partially composed
@term{filenames} for which an underlying @term{file system}
might not have a specific @term{namestring} representation.
A @term{pathname} need not correspond to any file that actually exists,
and more than one @term{pathname} can refer to the same file.
For example, the @term{pathname} with a version of @kwd{newest}
might refer to the same file as a @term{pathname}
with the same components except a certain number as the version.
Indeed, a @term{pathname} with version @kwd{newest} might refer to
different files as time passes, because the meaning of such a @term{pathname}
depends on the state of the file system.
Some @term{file systems} naturally use a structural model for their
@term{filenames}, while others do not. Within the @clisp{}@spc{}@term{pathname} model,
all @term{filenames} are seen as having a particular structure,
even if that structure is not reflected in the underlying @term{file system}.
The nature of the mapping between structure imposed by @term{pathnames}
and the structure, if any, that is used by the underlying @term{file system}
is @term{implementation-defined}.
Every @term{pathname} has six components:
a host,
a device,
a directory,
a name,
a type,
and a version.
By naming @term{files} with @term{pathnames},
@clisp{}@spc{}programs can work in essentially the same way even in @term{file systems}
that seem superficially quite different.
For a detailed description of these components, see @ref{Pathname Components}.
The mapping of the @term{pathname} components into the concepts peculiar to
each @term{file system} is @term{implementation-defined}.
There exist conceivable @term{pathnames}
for which there is no mapping to a syntactically valid @term{filename}
in a particular @term{implementation}.
An @term{implementation} may use various strategies in an attempt to find a mapping;
for example,
an @term{implementation} may quietly truncate @term{filenames}
that exceed length limitations imposed by the underlying @term{file system},
or ignore certain @term{pathname} components
for which the @term{file system} provides no support.
If such a mapping cannot be found,
an error @oftype{file-error} is signaled.
The time at which this mapping and associated error signaling
occurs is @term{implementation-dependent}.
Specifically, it may occur
at the time the @term{pathname} is constructed,
when coercing a @term{pathname} to a @term{namestring},
or when an attempt is made to @term{open} or otherwise access the @term{file}
designated by the @term{pathname}.
@Thenextfigure{}@spc{}lists some @term{defined names} that are applicable to @term{pathnames}.
@float Figure,fig19.1
@cartouche
@multitable{*default-pathname-defaults*}{pathname-directory}{user-homedir-pathname}
@item *default-pathname-defaults* @tab namestring @tab pathname-name
@item directory-namestring @tab open @tab pathname-type
@item enough-namestring @tab parse-namestring @tab pathname-version
@item file-namestring @tab pathname @tab pathnamep
@item file-string-length @tab pathname-device @tab translate-pathname
@item host-namestring @tab pathname-directory @tab truename
@item make-pathname @tab pathname-host @tab user-homedir-pathname
@item merge-pathnames @tab pathname-match-p @tab wild-pathname-p
@end multitable
@end cartouche
@caption{Pathname Operations}
@end float
@node Parsing Namestrings Into Pathnames
@subsection Parsing Namestrings Into Pathnames
Parsing is the operation used to convert a @term{namestring} into a @term{pathname}.
Except in the case of parsing @term{logical pathname} @term{namestrings},
this operation is @term{implementation-dependent},
because the format of @term{namestrings} is @term{implementation-dependent}.
A @term{conforming implementation} is free to accommodate other @term{file system}
features in its @term{pathname} representation and provides a parser that can process
such specifications in @term{namestrings}.
@term{Conforming programs} must not depend on any such features,
since those features will not be portable.
@node Pathnames
@section Pathnames
@menu
* Pathname Components::
* Interpreting Pathname Component Values::
* Merging Pathnames::
@end menu
@node Pathname Components
@subsection Pathname Components
A @term{pathname} has six components:
a host,
a device,
a directory,
a name,
a type,
and a version.
@node The Pathname Host Component
@subsubsection The Pathname Host Component
The name of the file system on which the file resides,
or the name of a @term{logical host}.
@node The Pathname Device Component
@subsubsection The Pathname Device Component
Corresponds to the ``device'' or ``file structure'' concept in many
host file systems: the name of a logical or physical device containing files.
@node The Pathname Directory Component
@subsubsection The Pathname Directory Component
Corresponds to the ``directory'' concept in many host file systems:
the name of a group of related files.
@node The Pathname Name Component
@subsubsection The Pathname Name Component
The ``name'' part of a group of @term{files} that can be thought of
as conceptually related.
@node The Pathname Type Component
@subsubsection The Pathname Type Component
Corresponds to the ``filetype'' or ``extension'' concept in many host
file systems. This says what kind of file this is.
This component is always a @term{string}, @nil{}, @kwd{wild}, or @kwd{unspecific}.
@node The Pathname Version Component
@subsubsection The Pathname Version Component
Corresponds to the ``version number'' concept in many host file systems.
The version is either a positive @term{integer}
or a @term{symbol} from the following list:
@nil{}, @kwd{wild}, @kwd{unspecific}, or @kwd{newest}
(refers to the largest version number that already exists in
the file system when reading a file, or to
a version number
greater than any already existing in the file system
when writing a new file). Implementations
can define other special version @term{symbols}.
@node Interpreting Pathname Component Values
@subsection Interpreting Pathname Component Values
@node Strings in Component Values
@subsubsection Strings in Component Values
@node Special Characters in Pathname Components
@subsubsection Special Characters in Pathname Components
@term{Strings} in @term{pathname} component values
never contain special @term{characters} that represent
separation between @term{pathname} fields,
such as @term{slash} in @Unix{}@spc{}@term{filenames}.
Whether separator @term{characters} are permitted as
part of a @term{string} in a @term{pathname} component
is @term{implementation-defined};
however, if the @term{implementation} does permit it,
it must arrange to properly ``quote'' the character for the
@term{file system} when constructing a @term{namestring}.
For example,
@lisp
;; In a TOPS-20 implementation, which uses @hat{}V to quote
(NAMESTRING (MAKE-PATHNAME :HOST "OZ" :NAME "<TEST>"))
@EV{} #P"OZ:PS:@hat{}V<TEST@hat{}V>"
@NV{} #P"OZ:PS:<TEST>"
@end lisp
@node Case in Pathname Components
@subsubsection Case in Pathname Components
@term{Namestrings} always use local file system @term{case} conventions,
but @clisp{}@spc{}@term{functions} that manipulate @term{pathname} components
allow the caller to select either of two conventions for representing
@term{case} in component values by supplying a value for the
@kwd{case} keyword argument.
@Thenextfigure{}@spc{}lists the functions
relating to @term{pathnames} that permit a @kwd{case} argument:
@float Figure,PathnameCaseFuns
@cartouche
@multitable{pathname-device}{pathname-directory}{pathname-name}
@item make-pathname @tab pathname-directory @tab pathname-name
@item pathname-device @tab pathname-host @tab pathname-type
@end multitable
@end cartouche
@caption{Pathname functions using a :CASE argument}
@end float
@node Local Case in Pathname Components
@subsubsection Local Case in Pathname Components
For the functions in @ref{PathnameCaseFuns, Figure 19.2},
a value of @kwd{local}
@cindex :local
for the @kwd{case} argument
(the default for these functions)
indicates that the functions should receive and yield @term{strings} in component values
as if they were already represented according to the host @term{file system}'s
convention for @term{case}.
If the @term{file system} supports both @term{cases}, @term{strings} given or received
as @term{pathname} component values under this protocol are to be used exactly
as written. If the file system only supports one @term{case},
the @term{strings} will be translated to that @term{case}.
@node Common Case in Pathname Components
@subsubsection Common Case in Pathname Components
For the functions in @ref{PathnameCaseFuns, Figure 19.2},
a value of @kwd{common}
@cindex :common
for the @kwd{case} argument
that these @term{functions} should receive
and yield @term{strings} in component values according to the following conventions:
@itemize @bullet{}
@item
All @term{uppercase} means to use a file system's customary @term{case}.
@item
All @term{lowercase} means to use the opposite of the customary @term{case}.
@item
Mixed @term{case} represents itself.
@end itemize
Note that these conventions have been chosen in such a way that translation
from @kwd{local} to @kwd{common} and back to @kwd{local} is information-preserving.
@node Special Pathname Component Values
@subsubsection Special Pathname Component Values
@node NIL as a Component Value
@subsubsection NIL as a Component Value
As a @term{pathname} component value,
@nil{} represents that the component is ``unfilled'';
see @ref{Merging Pathnames}.
The value of any @term{pathname} component can be @nil{}.
When constructing a @term{pathname},
@nil{}@spc{}in the host component might mean a default host
rather than an actual @nil{}@spc{}in some @term{implementations}.
@node WILD as a Component Value
@subsubsection :WILD as a Component Value
If @kwd{wild}
@cindex :wild
is the value of a @term{pathname} component,
that component is considered to be a wildcard, which matches anything.
A @term{conforming program} must be prepared to encounter a value of @kwd{wild}
as the value of any @term{pathname} component,
or as an @term{element} of a @term{list} that is the value of the directory component.
When constructing a @term{pathname},
a @term{conforming program} may use @kwd{wild} as the value of any or all of
the directory, name, type,
or version component, but must not use @kwd{wild} as the value of the host,
or device component.
If @kwd{wild} is used as the value of the directory component in the construction
of a @term{pathname}, the effect is equivalent to specifying the list
@f{(:absolute :wild-inferiors)},
or the same as @f{(:absolute :wild)} in a @term{file system} that does not support
@kwd{wild-inferiors}.
@cindex :wild-inferiors
@node UNSPECIFIC as a Component Value
@subsubsection :UNSPECIFIC as a Component Value
If @kwd{unspecific}
@cindex :unspecific
is the value of a @term{pathname} component,
the component is considered to be ``absent''
or to ``have no meaning''
in the @term{filename} being represented by the @term{pathname}.
Whether a value of @kwd{unspecific} is permitted for any component
on any given @term{file system} accessible to the @term{implementation}
is @term{implementation-defined}.
A @term{conforming program} must never unconditionally use a
@kwd{unspecific} as the value of a @term{pathname} component because
such a value is not guaranteed to be permissible in all implementations.
However, a @term{conforming program} can, if it is careful,
successfully manipulate user-supplied data
which contains or refers to non-portable @term{pathname} components.
And certainly a @term{conforming program} should be prepared for the
possibility that any components of a @term{pathname} could be @kwd{unspecific}.
When @term{reading}@sub{1} the value of any @term{pathname} component,
@term{conforming programs} should be prepared for the value to be @kwd{unspecific}.
When @term{writing}@sub{1} the value of any @term{pathname} component,
the consequences are undefined if @kwd{unspecific} is given
for a @term{pathname} in a @term{file system} for which it does not make sense.
@node Relation between component values NIL and :UNSPECIFIC
@subsubsection Relation between component values NIL and :UNSPECIFIC
If a @term{pathname} is converted to a @term{namestring},
the @term{symbols} @nil{}@spc{}and @kwd{unspecific}
cause the field to be treated as if it were empty.
That is,
both @nil{}@spc{}and @kwd{unspecific}
cause the component not to appear in the @term{namestring}.
However, when merging a @term{pathname} with a set of defaults,
only a @nil{}@spc{}value for a component
will be replaced with the default for that component,
while a value of @kwd{unspecific}
will be left alone as if the field were ``filled'';
see the @term{function} @ref{merge-pathnames} and @ref{Merging Pathnames}.
@node Restrictions on Wildcard Pathnames
@subsubsection Restrictions on Wildcard Pathnames
Wildcard @term{pathnames} can be used with @symbolref{directory, SYM} but not with
@symbolref{open, SYM},
and return true from @symbolref{wild-pathname-p, SYM}. When examining
wildcard components of a wildcard @term{pathname}, conforming programs
must be prepared to encounter any of the following additional values
in any component or any element of a @term{list} that is the directory component:
@itemize @bullet{}
@item The @term{symbol} @kwd{wild}, which matches anything.
@item A @term{string} containing @term{implementation-dependent}
special wildcard @term{characters}.
@item Any @term{object},
representing an @term{implementation-dependent} wildcard pattern.
@end itemize
@node Restrictions on Examining Pathname Components
@subsubsection Restrictions on Examining Pathname Components
The space of possible @term{objects} that a @term{conforming program}
must be prepared to @term{read}@sub{1}
as the value of a @term{pathname} component
is substantially larger than the space of possible @term{objects}
that a @term{conforming program} is permitted to @term{write}@sub{1}
into such a component.
While the values discussed
in the subsections of this section,
in @ref{Special Pathname Component Values},
and in @ref{Restrictions on Wildcard Pathnames}
apply to values that might be seen when
reading the component values,
substantially more restrictive rules apply to constructing pathnames;
see @ref{Restrictions on Constructing Pathnames}.
When examining @term{pathname} components,
@term{conforming programs} should be aware of the following restrictions.
@node Restrictions on Examining a Pathname Host Component
@subsubsection Restrictions on Examining a Pathname Host Component
It is @term{implementation-dependent} what @term{object} is used to represent the host.
@node Restrictions on Examining a Pathname Device Component
@subsubsection Restrictions on Examining a Pathname Device Component
The device might be a @term{string},
@kwd{wild}, @kwd{unspecific}, or @nil{}.
Note that @kwd{wild} might result from an attempt to @term{read}@sub{1}
the @term{pathname} component, even though portable programs are restricted
from @term{writing}@sub{1} such a component value;
see @ref{Restrictions on Constructing Pathnames}.
@node Restrictions on Examining a Pathname Directory Component
@subsubsection Restrictions on Examining a Pathname Directory Component
The directory might be a @term{string},
@kwd{wild}, @kwd{unspecific}, or @nil{}.
The directory can be a @term{list} of @term{strings} and @term{symbols}.
The @term{car} of the @term{list} is one of the symbols @kwd{absolute}
@cindex :absolute
or
@kwd{relative}
@cindex :relative
, meaning:
@table @asis
@item @id{@kwd{absolute}}
A @term{list} whose @term{car} is the symbol @kwd{absolute} represents
a directory path starting from the root directory. The list
@f{(:absolute)} represents the root directory. The list
@f{(:absolute "foo" "bar" "baz")} represents the directory called
@f{"/foo/bar/baz"} in Unix (except possibly for @term{case}).
@item @id{@kwd{relative}}
A @term{list} whose @term{car} is the symbol @kwd{relative} represents
a directory path starting from a default directory.
The list @f{(:relative)} has the same meaning as @nil{}@spc{}and hence is not used.
The list @tt{(:relative "foo" "bar")} represents the directory named @tt{"bar"}
in the directory named @tt{"foo"} in the default directory.
@end table
Each remaining element of the @term{list} is a @term{string} or a @term{symbol}.
Each @term{string} names a single level of directory structure.
The @term{strings} should contain only the directory names
themselves---no punctuation characters.
In place of a @term{string}, at any point in the @term{list}, @term{symbols}
can occur to indicate special file notations.
@Thenextfigure{}@spc{}lists the @term{symbols} that have standard meanings.
Implementations are permitted to add additional @term{objects}
of any @term{type} that is disjoint from @symbolref{string, SC}
if necessary to represent features of their file systems that cannot be
represented with the standard @term{strings} and @term{symbols}.
Supplying any non-@term{string}, including any of the @term{symbols} listed below,
to a file system for which it does not make sense
signals an error @oftype{file-error}.
For example, Unix does not support @kwd{wild-inferiors} in most implementations.
@cindex :wild
@cindex :wild-inferiors
@cindex :up
@cindex :back
@float Figure,fig19.3
@cartouche
@multitable{@kwd{wild-inferiors}}{Wildcard match of one level of directory structure}
@headitem Symbol @tab Meaning
@item @kwd{wild} @tab Wildcard match of one level of directory structure
@item @kwd{wild-inferiors} @tab Wildcard match of any number of directory levels
@item @kwd{up} @tab Go upward in directory structure (semantic)
@item @kwd{back} @tab Go upward in directory structure (syntactic)
@end multitable
@end cartouche
@caption{Special Markers In Directory Component}
@end float
The following notes apply to the previous figure:
@table @asis
@item @id{Invalid Combinations}
Using @kwd{absolute} or @kwd{wild-inferiors}
immediately followed by @kwd{up} or @kwd{back}
signals an error @oftype{file-error}.
@item @id{Syntactic vs Semantic}
``Syntactic'' means that the action of @kwd{back}
depends only on the @term{pathname}
and not on the contents of the file system.
``Semantic'' means that the action of @kwd{up}
depends on the contents of the file system;
to resolve a @term{pathname} containing
@kwd{up} to a @term{pathname} whose directory component
contains only @kwd{absolute} and
@term{strings} requires probing the file system.
@kwd{up} differs from
@kwd{back} only in file systems that support multiple
names for directories, perhaps via symbolic links. For example,
suppose that there is a directory
@f{(:absolute "X" "Y" "Z")}
linked to
@f{(:absolute "A" "B" "C")}
and there also exist directories
@f{(:absolute "A" "B" "Q")} and
@f{(:absolute "X" "Y" "Q")}.
Then
@f{(:absolute "X" "Y" "Z" :up "Q")}
designates
@f{(:absolute "A" "B" "Q")}
while
@f{(:absolute "X" "Y" "Z" :back "Q")}
designates
@f{(:absolute "X" "Y" "Q")}
@end table
@node Directory Components in Non-Hierarchical File Systems
@subsubsection Directory Components in Non-Hierarchical File Systems
In non-hierarchical @term{file systems},
the only valid @term{list} values for the directory component of a @term{pathname}
are @f{(:absolute @term{string})} and @f{(:absolute :wild)}.
@kwd{relative} directories and the keywords
@kwd{wild-inferiors}, @kwd{up}, and @kwd{back} are not used
in non-hierarchical @term{file systems}.
@node Restrictions on Examining a Pathname Name Component
@subsubsection Restrictions on Examining a Pathname Name Component
The name might be a @term{string},
@kwd{wild}, @kwd{unspecific}, or @nil{}.
@node Restrictions on Examining a Pathname Type Component
@subsubsection Restrictions on Examining a Pathname Type Component
The type might be a @term{string},
@kwd{wild}, @kwd{unspecific}, or @nil{}.
@node Restrictions on Examining a Pathname Version Component
@subsubsection Restrictions on Examining a Pathname Version Component
The version can be any @term{symbol} or any @term{integer}.
The symbol @kwd{newest} refers to the largest version number
that already exists in the @term{file system}
when reading, overwriting, appending, superseding, or directory listing
an existing @term{file}.
The symbol @kwd{newest} refers to the smallest version number
greater than any existing version number when creating a new file.
The symbols @nil{}, @kwd{unspecific}, and @kwd{wild} have special meanings and
restrictions; see @ref{Special Pathname Component Values}@spc{}and @ref{Restrictions on Constructing Pathnames}.
Other @term{symbols} and @term{integers}
have @term{implementation-defined} meaning.
@node Notes about the Pathname Version Component
@subsubsection Notes about the Pathname Version Component
It is suggested, but not required, that implementations do the following:
@itemize @bullet{}
@item Use positive @term{integers} starting at 1 as version numbers.
@item Recognize the symbol @kwd{oldest}
to designate the smallest existing version number.
@item Use @term{keywords} for other special versions.
@end itemize
@node Restrictions on Constructing Pathnames
@subsubsection Restrictions on Constructing Pathnames
When constructing a @term{pathname} from components, conforming programs
must follow these rules:
@itemize @bullet{}
@item
Any component can be @nil{}.
@nil{}@spc{}in the host might mean a default host
rather than an actual @nil{}@spc{}in some implementations.
@item
The host, device, directory, name, and type can be @term{strings}. There
are @term{implementation-dependent} limits on the number and type of
@term{characters} in these @term{strings}.
@item
The directory can be a @term{list} of @term{strings} and @term{symbols}.
There are @term{implementation-dependent} limits on the @term{list}'s
length and contents.
@item
The version can be @kwd{newest}.
@item
Any component can be taken
from the corresponding component of another @term{pathname}.
When the two @term{pathnames} are for different file systems
(in implementations that support multiple file systems),
an appropriate translation occurs.
If no meaningful translation is possible,
an error is signaled.
The definitions of ``appropriate'' and ``meaningful''
are @term{implementation-dependent}.
@item
An implementation might support other values for some components,
but a portable program cannot use those values.
A conforming program can use @term{implementation-dependent} values
but this can make it non-portable;
for example, it might work only with @Unix{}@spc{}file systems.
@end itemize
@node Merging Pathnames
@subsection Merging Pathnames
Merging takes a @term{pathname} with unfilled components
and supplies values for those components from a source of defaults.
If a component's value is @nil{}, that component is considered to be unfilled.
If a component's value is any @term{non-nil} @term{object},
including @kwd{unspecific}, that component is considered to be filled.
Except as explicitly specified otherwise,
for functions that manipulate or inquire about @term{files} in the @term{file system},
the pathname argument to such a function
is merged with @symbolref{*default-pathname-defaults*, SYM} before accessing the @term{file system}
(as if by @symbolref{merge-pathnames, SYM}).
@node Examples of Merging Pathnames
@subsubsection Examples of Merging Pathnames
Although the following examples are possible to execute only in
@term{implementations} which permit @kwd{unspecific} in the indicated
position andwhich permit four-letter type components, they serve to illustrate
the basic concept of @term{pathname} merging.
@medbreak{}
@lisp
(pathname-type
(merge-pathnames (make-pathname :type "LISP")
(make-pathname :type "TEXT")))
@EV{} "LISP"
@smallbreak{}
(pathname-type
(merge-pathnames (make-pathname :type nil)
(make-pathname :type "LISP")))
@EV{} "LISP"
@smallbreak{}
(pathname-type
(merge-pathnames (make-pathname :type :unspecific)
(make-pathname :type "LISP")))
@EV{} :UNSPECIFIC
@end lisp
@node Logical Pathnames
@section Logical Pathnames
@menu
* Syntax of Logical Pathname Namestrings::
* Logical Pathname Components::
@end menu
@node Syntax of Logical Pathname Namestrings
@subsection Syntax of Logical Pathname Namestrings
The syntax of a @term{logical pathname} @term{namestring} is as follows.
(Note that unlike many notational descriptions in this document,
this is a syntactic description of character sequences,
not a structural description of @term{objects}.)
@auxbnf{logical-pathname, @brac{@down{host} @param{host-marker}} @CR{} @brac{@down{@param{relative-directory-marker}}} @star{@curly{@down{directory} @param{directory-marker}}} @CR{} @brac{@down{name}} @brac{@param{type-marker} @down{type} @brac{@param{version-marker} @down{version}}}}
@auxbnf{host, @down{word}}
@auxbnf{directory, @down{word} | @down{wildcard-word} | @down{wild-inferiors-word}}
@auxbnf{name, @down{word} | @down{wildcard-word}}
@auxbnf{type, @down{word} | @down{wildcard-word}}
@auxbnf{version, @down{pos-int} | @param{newest-word} | @param{wildcard-version}}
@param{host-marker}---a @term{colon}.
@param{relative-directory-marker}---a @term{semicolon}.
@param{directory-marker}---a @term{semicolon}.
@param{type-marker}---a @term{dot}.
@param{version-marker}---a @term{dot}.
@param{wild-inferiors-word}---The two character sequence ``@f{**}'' (two @term{asterisks}).
@param{newest-word}---The six character sequence ``@f{newest}''
or the six character sequence ``@f{NEWEST}''.
@param{wildcard-version}---an @term{asterisk}.
@param{wildcard-word}---one or more @term{asterisks}, uppercase letters,
digits, and hyphens, including at least one @term{asterisk},
with no two @term{asterisks} adjacent.
@param{word}---one or more uppercase letters, digits, and hyphens.
@param{pos-int}---a positive @term{integer}.
@node Additional Information about Parsing Logical Pathname Namestrings
@subsubsection Additional Information about Parsing Logical Pathname Namestrings
@node The Host part of a Logical Pathname Namestring
@subsubsection The Host part of a Logical Pathname Namestring
The @param{host} must have been defined as a @term{logical pathname} host;
this can be done by using @symbolref{setf, SYM} of @symbolref{logical-pathname-translations, SYM}.
The @term{logical pathname} host name @f{"SYS"} is reserved for the implementation.
The existence and meaning of @f{SYS:} @term{logical pathnames}
is @term{implementation-defined}.
@node The Device part of a Logical Pathname Namestring
@subsubsection The Device part of a Logical Pathname Namestring
There is no syntax for a @term{logical pathname} device since
the device component of a @term{logical pathname} is always @kwd{unspecific};
see @ref{Unspecific Components of a Logical Pathname}.
@node The Directory part of a Logical Pathname Namestring
@subsubsection The Directory part of a Logical Pathname Namestring
If a @param{relative-directory-marker} precedes the @param{directories},
the directory component parsed is as @term{relative};
otherwise, the directory component is parsed as @term{absolute}.
If a @param{wild-inferiors-marker} is specified,
it parses into @kwd{wild-inferiors}.
@node The Type part of a Logical Pathname Namestring
@subsubsection The Type part of a Logical Pathname Namestring
The @param{type} of a @term{logical pathname} for a @term{source file}
is @f{"LISP"}. This should be translated into whatever type is
appropriate in a physical pathname.
@node The Version part of a Logical Pathname Namestring
@subsubsection The Version part of a Logical Pathname Namestring
Some @term{file systems} do not have @param{versions}.
@term{Logical pathname} translation to such a @term{file system}
ignores the @param{version}.
This implies that a program cannot rely on being able to store
more than one version of a file named by a @term{logical pathname}.
If a @param{wildcard-version} is specified,
it parses into @kwd{wild}.
@node Wildcard Words in a Logical Pathname Namestring
@subsubsection Wildcard Words in a Logical Pathname Namestring
Each @term{asterisk} in a @param{wildcard-word} matches a sequence of
zero or more characters. The @param{wildcard-word} ``@f{*}''
parses into @kwd{wild}; other @param{wildcard-words} parse into @term{strings}.
@node Lowercase Letters in a Logical Pathname Namestring
@subsubsection Lowercase Letters in a Logical Pathname Namestring
When parsing @param{words} and @param{wildcard-words},
lowercase letters are translated to uppercase.
@node Other Syntax in a Logical Pathname Namestring
@subsubsection Other Syntax in a Logical Pathname Namestring
The consequences of using characters other than those specified here
in a @term{logical pathname} @term{namestring} are unspecified.
The consequences of using any value not specified here as a
@term{logical pathname} component are unspecified.
@node Logical Pathname Components
@subsection Logical Pathname Components
@node Unspecific Components of a Logical Pathname
@subsubsection Unspecific Components of a Logical Pathname
The device component of a @term{logical pathname} is always @kwd{unspecific};
no other component of a @term{logical pathname} can be @kwd{unspecific}.
@node Null Strings as Components of a Logical Pathname
@subsubsection Null Strings as Components of a Logical Pathname
The null string, @f{""}, is not a valid value for any component of a @term{logical pathname}.
@node Filenames Dictionary
@section Filenames Dictionary
@menu
* pathname (System Class)::
* logical-pathname (System Class)::
* pathname (Function)::
* make-pathname::
* pathnamep::
* pathname-host; pathname-device; pathname-directory; pathname-name; path+::
* load-logical-pathname-translations::
* logical-pathname-translations::
* logical-pathname (Function)::
* *default-pathname-defaults*::
* namestring; file-namestring; directory-namestring; host-namestring; eno+::
* parse-namestring::
* wild-pathname-p::
* pathname-match-p::
* translate-logical-pathname::
* translate-pathname::
* merge-pathnames::
@end menu
@node pathname (System Class)
@syindexanchor{pathname, SC}
@subsection pathname (System Class)
@cindex pathname
@subsubheading Class Precedence List:
@symbolref{pathname, SC},
@symbolref{t, SC}
@subsubheading Description:
A @term{pathname} is a structured @term{object} which represents a @term{filename}.
There are two kinds of @term{pathnames}---@term{physical pathnames} and
@term{logical pathnames}.
@node logical-pathname (System Class)
@syindexanchor{logical-pathname-, SYM}
@subsection logical-pathname (System Class)
@cindex logical-pathname
@subsubheading Class Precedence List:
@symbolref{logical-pathname, SYM},
@symbolref{pathname, SC},
@symbolref{t, SC}
@subsubheading Description:
A @term{pathname} that uses a @term{namestring} syntax that is
@term{implementation-independent},
and that has component values that are @term{implementation-independent}.
@term{Logical pathnames} do not refer directly to @term{filenames}
@subsubheading See Also:
@ref{File System Concepts},
@ref{Sharpsign P},
@ref{Printing Pathnames}