concept-files.tex 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. % -*- Mode: TeX -*-
  2. %% 23.0.0 6 was left out.
  3. This section describes the \clisp\ interface to file systems.
  4. %% 23.0.0 5
  5. The model used by this interface assumes
  6. that \newtermidx{files}{file} are named by \newtermidx{filenames}{filename},
  7. that a \term{filename} can be represented by a \term{pathname} \term{object},
  8. and that given a \term{pathname} a \newterm{stream} can be constructed
  9. that connects to a \term{file} whose \term{filename} it represents.
  10. For information about opening and closing \term{files},
  11. and manipulating their contents, \seechapter\Streams.
  12. \Thenextfigure\ lists some \term{operators}
  13. that are applicable to \term{files} and directories.
  14. \displaythree{File and Directory Operations}{
  15. compile-file&file-length&open\cr
  16. delete-file&file-position&probe-file\cr
  17. directory&file-write-date&rename-file\cr
  18. file-author&load&with-open-file\cr
  19. }
  20. \beginsubsection{Coercion of Streams to Pathnames}
  21. \DefineSection{StreamsToPathnames}
  22. A \newterm{stream associated with a file} is either a \term{file stream}
  23. or a \term{synonym stream} whose target is a \newterm{stream associated with a file}.
  24. Such streams can be used as \term{pathname designators}.
  25. Normally, when a \term{stream associated with a file} is used as a
  26. \term{pathname designator}, it denotes the \term{pathname} used to
  27. open the \term{file}; this may be, but is not required to be, the
  28. actual name of the \term{file}.
  29. Some functions, such as \funref{truename} and \funref{delete-file},
  30. coerce \term{streams} to \term{pathnames} in a different way that
  31. involves referring to the actual \term{file} that is open, which might
  32. or might not be the file whose name was opened originally. Such special
  33. situations are always notated specifically and are not the default.
  34. \endsubsection%{Coercion of Streams to Pathnames}
  35. \beginsubsection{File Operations on Open and Closed Streams}
  36. \DefineSection{OpenAndClosedStreams}
  37. \issue{CLOSED-STREAM-FUNCTIONS:ALLOW-INQUIRY}
  38. Many \term{functions} that perform \term{file} operations accept either
  39. \term{open} or \term{closed} \term{streams} as \term{arguments};
  40. \seesection\StreamArgsToStandardizedFns.
  41. Of these, the \term{functions} in \thenextfigure\ treat \term{open} and
  42. \term{closed} \term{streams} differently.
  43. \displaythree{File Functions that Treat Open and Closed Streams Differently}{
  44. delete-file&file-author&probe-file\cr
  45. directory&file-write-date&truename\cr
  46. }
  47. Since treatment of \term{open} \term{streams} by the \term{file system}
  48. may vary considerably between \term{implementations}, however,
  49. a \term{closed} \term{stream} might be the most reliable kind of
  50. \term{argument} for some of these functions---in particular, those in
  51. \thenextfigure. For example, in some \term{file systems},
  52. \term{open} \term{files} are written under temporary names
  53. and not renamed until \term{closed}
  54. and/or are held invisible until \term{closed}.
  55. In general, any code that is intended to be portable should
  56. use such \term{functions} carefully.
  57. \displaythree{File Functions where Closed Streams Might Work Best}{
  58. directory&probe-file&truename\cr
  59. }
  60. \endissue{CLOSED-STREAM-FUNCTIONS:ALLOW-INQUIRY}
  61. \endsubsection%{File Operations on Open and Closed Streams}
  62. \beginsubsection{Truenames}
  63. \DefineSection{Truenames}
  64. Many \term{file systems} permit more than one \term{filename} to designate
  65. a particular \term{file}.
  66. Even where multiple names are possible, most \term{file systems} have a convention
  67. for generating a canonical \term{filename} in such situations. Such a canonical
  68. \term{filename} (or the \term{pathname} representing such a \term{filename}) is
  69. called a \newterm{truename}.
  70. %This came from the CLtL description of PROBE-FILE
  71. The \term{truename} of a \term{file} may differ from other \term{filenames}
  72. for the file because of
  73. symbolic links,
  74. version numbers,
  75. % Added to distinguish from Sandra's addition that follows. -kmp 12-Dec-91
  76. logical device translations in the \term{file system},
  77. % Added per Sandra. -kmp 12-Dec-91
  78. \term{logical pathname} translations within \clisp,
  79. or other artifacts of the \term{file system}.
  80. The \term{truename} for a \term{file} is often, but not necessarily, unique for
  81. each \term{file}. For instance, a Unix \term{file} with multiple hard links
  82. could have several \term{truenames}.
  83. \beginsubsubsection{Examples of Truenames}
  84. For example, a DEC TOPS-20 system with \term{files} \f{PS:<JOE>FOO.TXT.1}
  85. and \f{PS:<JOE>FOO.TXT.2} might permit the second \term{file} to be referred
  86. to as \f{PS:<JOE>FOO.TXT.0}, since the ``\f{.0}'' notation denotes ``newest''
  87. version of several \term{files}.
  88. In the same \term{file system}, a ``logical device'' ``\f{JOE:}'' might be
  89. taken to refer to \f{PS:<JOE>}'' and so the names \f{JOE:FOO.TXT.2} or
  90. \f{JOE:FOO.TXT.0} might refer to \f{PS:<JOE>FOO.TXT.2}.
  91. In all of these cases, the \term{truename} of the file would probably be
  92. \f{PS:<JOE>FOO.TXT.2}.
  93. If a \term{file} is a symbolic link to another \term{file} (in a \term{file system}
  94. permitting such a thing), it is conventional for the \term{truename} to be
  95. the canonical name of the \term{file} after any symbolic links have been followed;
  96. that is, it is the canonical name of the \term{file} whose contents would
  97. become available if an \term{input} \term{stream} to that \term{file} were
  98. opened.
  99. In the case of a \term{file} still being created (that is, of an \term{output}
  100. \term{stream} open to such a \term{file}), the exact \term{truename} of the file
  101. might not be known until the \term{stream} is closed. In this case,
  102. \thefunction{truename} might return different values for such a \term{stream}
  103. before and after it was closed. In fact, before it is closed, the name returned
  104. might not even be a valid name in the \term{file system}---for example, while a
  105. file is being written, it might have version \kwdref{newest} and might only take on
  106. a specific numeric value later when the file is closed even in a \term{file system}
  107. where all files have numeric versions.
  108. \endsubsubsection%{Examples of Truenames}
  109. \endsubsection%{Truenames}