concept-filenames.tex 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. % -*- Mode: TeX -*-
  2. There are many kinds of \term{file systems},
  3. varying widely both in their superficial syntactic details,
  4. and in their underlying power and structure.
  5. The facilities provided by \clisp\ for referring to and manipulating \term{files}
  6. has been chosen to be compatible with many kinds of \term{file systems},
  7. while at the same time minimizing the program-visible differences
  8. between kinds of \term{file systems}.
  9. %% 23.1.0 1
  10. Since \term{file systems} vary in their conventions for naming \term{files},
  11. there are two distinct ways to represent \term{filenames}:
  12. as \term{namestrings} and as \term{pathnames}.
  13. \beginSubsection{Namestrings as Filenames}
  14. \issue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  15. A \newterm{namestring} is a \term{string} that represents a \term{filename}.
  16. In general, the syntax of \term{namestrings} involves the use of
  17. \term{implementation-defined} conventions,
  18. usually those customary for the \term{file system} in which the named \term{file} resides.
  19. The only exception is the syntax of a \term{logical pathname} \term{namestring},
  20. which is defined in this specification; \seesection\LogPathNamestrings.
  21. \endissue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  22. A \term{conforming program} must never unconditionally use a
  23. \term{literal} \term{namestring} other than a \term{logical pathname} \term{namestring}
  24. because \clisp\ does not define any \term{namestring} syntax
  25. other than that for \term{logical pathnames}
  26. that would be guaranteed to be portable.
  27. However, a \term{conforming program} can, if it is careful,
  28. successfully manipulate user-supplied data
  29. which contains or refers to non-portable \term{namestrings}.
  30. %%% 23.1.1 11
  31. A \term{namestring} can be \term{coerced} to a \term{pathname} by \thefunctions{pathname}
  32. or \funref{parse-namestring}.
  33. %% Not true for logical pathnames. Anyway, better said (if at all) in the function entries.
  34. % The effect of these \term{functions} is necessarily
  35. % \term{implementation-dependent} because the format of \term{namestrings}
  36. % is \term{implementation-dependent}.
  37. \endSubsection%{Namestrings as Filenames}
  38. \beginSubsection{Pathnames as Filenames}
  39. \DefineSection{PathnamesAsFilenames}
  40. % From Chapter 21.1 ...
  41. %
  42. % \term{Pathnames} provide a means for expressing many operations that
  43. % manipulate files or file names in a manner that does not depend on the specific
  44. % format of file names on a particular file system.
  45. \newtermidx{Pathnames}{pathname} are structured \term{objects} that can represent,
  46. in an \term{implementation-independent} way,
  47. the \term{filenames} that are used natively by an underlying \term{file system}.
  48. In addition, \term{pathnames} can also represent certain partially composed
  49. \term{filenames} for which an underlying \term{file system}
  50. might not have a specific \term{namestring} representation.
  51. %% 23.1.1 10
  52. % A \term{pathname}
  53. % is not necessarily the name of a specific file.
  54. % Rather, it is a specification (possibly only a partial specification) of
  55. % how to access a file.
  56. A \term{pathname} need not correspond to any file that actually exists,
  57. and more than one \term{pathname} can refer to the same file.
  58. For example, the \term{pathname} with a version of \kwd{newest}
  59. might refer to the same file as a \term{pathname}
  60. with the same components except a certain number as the version.
  61. Indeed, a \term{pathname} with version \kwd{newest} might refer to
  62. different files as time passes, because the meaning of such a \term{pathname}
  63. depends on the state of the file system.
  64. Some \term{file systems} naturally use a structural model for their
  65. \term{filenames}, while others do not. Within the \clisp\ \term{pathname} model,
  66. all \term{filenames} are seen as having a particular structure,
  67. even if that structure is not reflected in the underlying \term{file system}.
  68. The nature of the mapping between structure imposed by \term{pathnames}
  69. and the structure, if any, that is used by the underlying \term{file system}
  70. is \term{implementation-defined}.
  71. %% 23.1.0 2
  72. %In order to allow code to operate in a network environment
  73. %that may have more than one kind of file system, the pathname facility
  74. %allows a file name to specify which file system (called the
  75. %host) is to be used.
  76. %Left out.
  77. %% 23.1.1 3
  78. Every \term{pathname} has six components:
  79. a host,
  80. a device,
  81. a directory,
  82. a name,
  83. a type,
  84. and a version.
  85. By naming \term{files} with \term{pathnames},
  86. \clisp\ programs can work in essentially the same way even in \term{file systems}
  87. that seem superficially quite different.
  88. For a detailed description of these components, \seesection\PathnameComponents.
  89. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  90. \issue{PATHNAME-SYNTAX-ERROR-TIME:EXPLICITLY-VAGUE}%
  91. % %% Per X3J13. -kmp 5-Oct-93
  92. % The mapping of the \term{pathname} components into the concepts peculiar to
  93. % each \term{file system} is \term{implementation-defined}.
  94. % There exist conceivable \term{pathnames} for which there is no valid mapping
  95. % in a particular \term{implementation}. The time at which this error detection
  96. % occurs is \term{implementation-dependent}.
  97. The mapping of the \term{pathname} components into the concepts peculiar to
  98. each \term{file system} is \term{implementation-defined}.
  99. There exist conceivable \term{pathnames}
  100. for which there is no mapping to a syntactically valid \term{filename}
  101. in a particular \term{implementation}.
  102. An \term{implementation} may use various strategies in an attempt to find a mapping;
  103. for example,
  104. an \term{implementation} may quietly truncate \term{filenames}
  105. that exceed length limitations imposed by the underlying \term{file system},
  106. or ignore certain \term{pathname} components
  107. for which the \term{file system} provides no support.
  108. If such a mapping cannot be found,
  109. an error \oftype{file-error} is signaled.
  110. The time at which this mapping and associated error signaling
  111. occurs is \term{implementation-dependent}.
  112. Specifically, it may occur
  113. at the time the \term{pathname} is constructed,
  114. when coercing a \term{pathname} to a \term{namestring},
  115. or when an attempt is made to \term{open} or otherwise access the \term{file}
  116. designated by the \term{pathname}.
  117. \endissue{PATHNAME-SYNTAX-ERROR-TIME:EXPLICITLY-VAGUE}
  118. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  119. \Thenextfigure\ lists some \term{defined names} that are applicable to \term{pathnames}.
  120. \displaythree{Pathname Operations}{
  121. *default-pathname-defaults*&namestring&pathname-name\cr
  122. directory-namestring&open&pathname-type\cr
  123. enough-namestring&parse-namestring&pathname-version\cr
  124. file-namestring&pathname&pathnamep\cr
  125. file-string-length&pathname-device&translate-pathname\cr
  126. host-namestring&pathname-directory&truename\cr
  127. make-pathname&pathname-host&user-homedir-pathname\cr
  128. merge-pathnames&pathname-match-p&wild-pathname-p\cr
  129. }
  130. \endSubsection%{Pathnames as Filenames}
  131. \beginSubsection{Parsing Namestrings Into Pathnames}
  132. %% 23.1.1 11
  133. Parsing is the operation used to convert a \term{namestring} into a \term{pathname}.
  134. \issue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  135. Except in the case of parsing \term{logical pathname} \term{namestrings},
  136. \endissue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  137. this operation is \term{implementation-dependent},
  138. because the format of \term{namestrings} is \term{implementation-dependent}.
  139. %% 23.1.1 20
  140. A \term{conforming implementation} is free to accommodate other \term{file system}
  141. features in its \term{pathname} representation and provides a parser that can process
  142. such specifications in \term{namestrings}.
  143. \term{Conforming programs} must not depend on any such features,
  144. since those features will not be portable.
  145. \endSubsection%{Parsing Namestrings Into Pathnames}