dict-pathnames.tex 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939
  1. % -*- Mode: TeX -*-
  2. % Pathnames
  3. % Logical Pathnames
  4. % Parsing
  5. % Namestrings
  6. % Pathname Matching
  7. % Pathname Merging
  8. %-------------------- Pathname Types --------------------
  9. \begincom{pathname}\ftype{System Class}
  10. \label Class Precedence List::
  11. \typeref{pathname},
  12. \typeref{t}
  13. \label Description::
  14. A \term{pathname} is a structured \term{object} which represents a \term{filename}.
  15. There are two kinds of \term{pathnames}---\term{physical pathnames} and
  16. \term{logical pathnames}.
  17. \endcom%{pathname}\ftype{System Class}
  18. \begincom{logical-pathname}\ftype{System Class}
  19. \issue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  20. \label Class Precedence List::
  21. \typeref{logical-pathname},
  22. \typeref{pathname},
  23. \typeref{t}
  24. \label Description::
  25. A \term{pathname} that uses a \term{namestring} syntax that is
  26. \term{implementation-independent},
  27. and that has component values that are \term{implementation-independent}.
  28. \term{Logical pathnames} do not refer directly to \term{filenames}
  29. %!!! Barmar: Needs more description. e.g.,
  30. % an implementation-independent pathname that is automatically translated
  31. % to a pathname when it is used.
  32. %
  33. % Relate to physical pathname.
  34. \label See Also::
  35. {\secref\FileSystemConcepts},
  36. {\secref\SharpsignP},
  37. {\secref\PrintingPathnames}
  38. \endissue{TYPE-OF-AND-PREDEFINED-CLASSES:UNIFY-AND-EXTEND}
  39. \endcom%{logical-pathname}\ftype{System Class}
  40. %-------------------- Pathnames --------------------
  41. %%% ========== PATHNAME
  42. \begincom{pathname}\ftype{Function}
  43. \label Syntax::
  44. \DefunWithValues pathname {pathspec} {pathname}
  45. \label Arguments and Values::
  46. \issue{PATHNAME-STREAM}
  47. \param{pathspec}---a \term{pathname designator}.
  48. \endissue{PATHNAME-STREAM}
  49. \param{pathname}---a \term{pathname}.
  50. \label Description::
  51. Returns the \term{pathname} denoted by \param{pathspec}.
  52. %% 23.1.2 5
  53. % \funref{pathname} converts \param{pathspec} to a \term{pathname}
  54. % and returns the new \term{pathname}.
  55. % If \param{pathspec} is a \term{stream}
  56. % it represents the name used to open the file. This may be, but is
  57. % not required to be, the actual name of the file.
  58. \issue{CLOSED-STREAM-FUNCTIONS:ALLOW-INQUIRY}
  59. If the \param{pathspec} \term{designator} is a \term{stream},
  60. the \term{stream} can be either open or closed;
  61. in both cases, the \funref{pathname} returned
  62. corresponds to the \term{filename} used to open the \term{file}.
  63. \funref{pathname} returns the same \term{pathname} for a \term{file stream}
  64. after it is closed as it did when it was open.
  65. \endissue{CLOSED-STREAM-FUNCTIONS:ALLOW-INQUIRY}
  66. \issue{PATHNAME-LOGICAL:ADD}
  67. % created by \funref{open}
  68. % or \macref{with-open-file} of a \term{logical pathname},
  69. %\funref{pathname} returns a \term{logical pathname}.
  70. If the \param{pathspec} \term{designator} is
  71. a \term{file stream} created by opening a \term{logical pathname},
  72. a \term{logical pathname} is returned.
  73. \endissue{PATHNAME-LOGICAL:ADD}
  74. % \issue{PATHNAME-STREAM}
  75. % It is an error if \param{pathspec} is a \term{stream} that is
  76. % created with \funref{make-two-way-stream},
  77. % \funref{make-echo-stream},
  78. % \funref{make-broadcast-stream},
  79. % \funref{make-concatenated-stream}, \funref{make-string-input-stream},
  80. % \funref{make-string-output-stream}.
  81. % \endissue{PATHNAME-STREAM}
  82. \label Examples::
  83. \code
  84. ;; There is a great degree of variability permitted here. The next
  85. ;; several examples are intended to illustrate just a few of the many
  86. ;; possibilities. Whether the name is canonicalized to a particular
  87. ;; case (either upper or lower) depends on both the file system and the
  88. ;; implementation since two different implementations using the same
  89. ;; file system might differ on many issues. How information is stored
  90. ;; internally (and possibly presented in #S notation) might vary,
  91. ;; possibly requiring `accessors' such as PATHNAME-NAME to perform case
  92. ;; conversion upon access. The format of a namestring is dependent both
  93. ;; on the file system and the implementation since, for example, one
  94. ;; implementation might include the host name in a namestring, and
  95. ;; another might not. #S notation would generally only be used in a
  96. ;; situation where no appropriate namestring could be constructed for use
  97. ;; with #P.
  98. (setq p1 (pathname "test"))
  99. \EV #P"CHOCOLATE:TEST" ; with case canonicalization (e.g., VMS)
  100. \OV #P"VANILLA:test" ; without case canonicalization (e.g., Unix)
  101. \OV #P"test"
  102. \OV #S(PATHNAME :HOST "STRAWBERRY" :NAME "TEST")
  103. \OV #S(PATHNAME :HOST "BELGIAN-CHOCOLATE" :NAME "test")
  104. (setq p2 (pathname "test"))
  105. \EV #P"CHOCOLATE:TEST"
  106. \OV #P"VANILLA:test"
  107. \OV #P"test"
  108. \OV #S(PATHNAME :HOST "STRAWBERRY" :NAME "TEST")
  109. \OV #S(PATHNAME :HOST "BELGIAN-CHOCOLATE" :NAME "test")
  110. (pathnamep p1) \EV \term{true}
  111. (eq p1 (pathname p1)) \EV \term{true}
  112. (eq p1 p2)
  113. \EV \term{true}
  114. \OV \term{false}
  115. (with-open-file (stream "test" :direction :output)
  116. (pathname stream))
  117. \EV #P"ORANGE-CHOCOLATE:>Gus>test.lisp.newest"
  118. \endcode
  119. \label Affected By:\None.
  120. \label Exceptional Situations:\None.
  121. \label See Also::
  122. \issue{PATHNAME-LOGICAL:ADD}
  123. \typeref{pathname},
  124. \typeref{logical-pathname},
  125. {\secref\FileSystemConcepts},
  126. \endissue{PATHNAME-LOGICAL:ADD}
  127. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  128. {\secref\PathnamesAsFilenames}
  129. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  130. \label Notes:\None.
  131. %% 23.1.2 4
  132. %% was left out
  133. \endcom%{pathname}
  134. %%% ========== MAKE-PATHNAME
  135. \begincom{make-pathname}\ftype{Function}
  136. \label Syntax::
  137. \DefunWithValuesNewline make-pathname
  138. {{\key} host device directory name type version defaults case}
  139. {pathname}
  140. \label Arguments and Values::
  141. \issue{PATHNAME-UNSPECIFIC-COMPONENT:NEW-TOKEN}
  142. \param{host}---a \term{valid physical pathname host}.
  143. %%Per X3J13. -kmp 05-Oct-93.
  144. \HairyDefault.
  145. \param{device}---a \term{valid pathname device}.
  146. %%Per X3J13. -kmp 05-Oct-93.
  147. \HairyDefault.
  148. \param{directory}---a \term{valid pathname directory}.
  149. %%Per X3J13. -kmp 05-Oct-93.
  150. \HairyDefault.
  151. \param{name}---a \term{valid pathname name}.
  152. %%Per X3J13. -kmp 05-Oct-93.
  153. \HairyDefault.
  154. \param{type}---a \term{valid pathname type}.
  155. %%Per X3J13. -kmp 05-Oct-93.
  156. \HairyDefault.
  157. \param{version}---a \term{valid pathname version}.
  158. %%Per X3J13. -kmp 05-Oct-93
  159. \HairyDefault.
  160. \endissue{PATHNAME-UNSPECIFIC-COMPONENT:NEW-TOKEN}
  161. \param{defaults}---a \term{pathname designator}.
  162. \Default{a \term{pathname} whose host component is the same as the
  163. host component of \thevalueof{*default-pathname-defaults*},
  164. and whose other components are all \nil}
  165. \issue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  166. \param{case}---one of \kwd{common} or \kwd{local}.
  167. \Default{\kwd{local}}
  168. \endissue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  169. \param{pathname}---a \term{pathname}.
  170. \label Description::
  171. %% 23.1.2 27
  172. Constructs and returns a \term{pathname} from the supplied keyword arguments.
  173. After the components supplied explicitly by
  174. \param{host},
  175. \param{device},
  176. \param{directory},
  177. \param{name},
  178. \param{type},
  179. and \param{version}
  180. are filled in,
  181. the merging rules used by \funref{merge-pathnames}
  182. are used to fill in any
  183. %%Per X3J13. -kmp 05-Oct-93.
  184. %missing
  185. unsupplied
  186. components
  187. from the defaults supplied by \param{defaults}.
  188. %% 23.1.2 28
  189. Whenever a \term{pathname} is constructed the components may be
  190. canonicalized if appropriate.
  191. %For example, if a file system is insensitive to case, then
  192. %characters with case may be forced to be all uppercase or all lowercase
  193. %by the implementation.
  194. For the explanation of the arguments that can be supplied for each component,
  195. \seesection\PathnameComponents.
  196. \issue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  197. If \param{case} is supplied,
  198. it is treated as described in \secref\PathnameComponentCase.
  199. \endissue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  200. \issue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  201. \issue{PATHNAME-LOGICAL:ADD}
  202. The resulting \param{pathname} is a \term{logical pathname}
  203. if and only its host component
  204. %denotes
  205. is
  206. a \term{logical host}
  207. or a \term{string} that names a defined \term{logical host}.
  208. % If \param{host} is supplied,
  209. % the host is logical if it came from \funref{pathname-host} of a \term{logical pathname}.
  210. % Whether \param{host} denotes a \term{logical host} if it is a \term{string}
  211. % that is equal to the \term{name} of a \term{logical host} is \term{implementation-defined}.
  212. \endissue{PATHNAME-LOGICAL:ADD}
  213. \endissue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  214. \issue{PATHNAME-SUBDIRECTORY-LIST:NEW-REPRESENTATION}
  215. %!!! Laddaga: Clearly this should also be presented in the concept section.
  216. If the \param{directory} is a \term{string},
  217. it should be the name of a top level directory,
  218. and should not contain any punctuation characters; that is,
  219. specifying a \term{string}, \i{str}, is
  220. equivalent to specifying the list \f{(:absolute \i{str})}.
  221. Specifying the symbol \kwd{wild} is equivalent to specifying the list
  222. \f{(:absolute :wild-inferiors)}, or \f{(:absolute :wild)}
  223. in a file system that does not support \kwd{wild-inferiors}.
  224. \endissue{PATHNAME-SUBDIRECTORY-LIST:NEW-REPRESENTATION}
  225. \label Examples::
  226. \code
  227. ;; Implementation A -- an implementation with access to a single
  228. ;; Unix file system. This implementation happens to never display
  229. ;; the `host' information in a namestring, since there is only one host.
  230. (make-pathname :directory '(:absolute "public" "games")
  231. :name "chess" :type "db")
  232. \EV #P"/public/games/chess.db"
  233. \medbreak
  234. ;; Implementation B -- an implementation with access to one or more
  235. ;; VMS file systems. This implementation displays `host' information
  236. ;; in the namestring only when the host is not the local host.
  237. ;; It uses a double colon to separate a host name from the host's local
  238. ;; file name.
  239. (make-pathname :directory '(:absolute "PUBLIC" "GAMES")
  240. :name "CHESS" :type "DB")
  241. \EV #P"SYS$DISK:[PUBLIC.GAMES]CHESS.DB"
  242. (make-pathname :host "BOBBY"
  243. :directory '(:absolute "PUBLIC" "GAMES")
  244. :name "CHESS" :type "DB")
  245. \EV #P"BOBBY::SYS$DISK:[PUBLIC.GAMES]CHESS.DB"
  246. \medbreak
  247. ;; Implementation C -- an implementation with simultaneous access to
  248. ;; multiple file systems from the same Lisp image. In this
  249. ;; implementation, there is a convention that any text preceding the
  250. ;; first colon in a pathname namestring is a host name.
  251. (dolist (case '(:common :local))
  252. (dolist (host '("MY-LISPM" "MY-VAX" "MY-UNIX"))
  253. (print (make-pathname :host host :case case
  254. :directory '(:absolute "PUBLIC" "GAMES")
  255. :name "CHESS" :type "DB"))))
  256. \OUT #P"MY-LISPM:>public>games>chess.db"
  257. \OUT #P"MY-VAX:SYS$DISK:[PUBLIC.GAMES]CHESS.DB"
  258. \OUT #P"MY-UNIX:/public/games/chess.db"
  259. \OUT #P"MY-LISPM:>public>games>chess.db"
  260. \OUT #P"MY-VAX:SYS$DISK:[PUBLIC.GAMES]CHESS.DB"
  261. \OUT #P"MY-UNIX:/PUBLIC/GAMES/CHESS.DB"
  262. \EV NIL
  263. \endcode
  264. \label Affected By::
  265. The \term{file system}.
  266. \label Exceptional Situations:\None.
  267. \label See Also::
  268. \issue{PATHNAME-LOGICAL:ADD}
  269. \funref{merge-pathnames},
  270. \typeref{pathname},
  271. \typeref{logical-pathname},
  272. {\secref\FileSystemConcepts},
  273. \endissue{PATHNAME-LOGICAL:ADD}
  274. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  275. {\secref\PathnamesAsFilenames}
  276. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  277. \label Notes::
  278. Portable programs should not supply \kwd{unspecific} for any component.
  279. \Seesection\UnspecificComponent.
  280. \endcom%{make-pathname}
  281. %%% ========== PATHNAMEP
  282. \begincom{pathnamep}\ftype{Function}
  283. \label Syntax::
  284. \DefunWithValues pathnamep {object} {generalized-boolean}
  285. \label Arguments and Values::
  286. \param{object}---an \term{object}.
  287. \param{generalized-boolean}---a \term{generalized boolean}.
  288. \label Description::
  289. %% 23.1.2 29
  290. \TypePredicate{object}{pathname}
  291. \label Examples::
  292. \code
  293. (setq q "test") \EV "test"
  294. (pathnamep q) \EV \term{false}
  295. (setq q (pathname "test"))
  296. \EV #S(PATHNAME :HOST NIL :DEVICE NIL :DIRECTORY NIL :NAME "test" :TYPE NIL
  297. :VERSION NIL)
  298. (pathnamep q) \EV \term{true}
  299. (setq q (logical-pathname "SYS:SITE;FOO.SYSTEM"))
  300. \EV #P"SYS:SITE;FOO.SYSTEM"
  301. (pathnamep q) \EV \term{true}
  302. \endcode
  303. \label Side Effects:\None.
  304. \label Affected By:\None.
  305. \label Exceptional Situations:\None!
  306. \label See Also:\None.
  307. \label Notes::
  308. \code
  309. (pathnamep \param{object}) \EQ (typep \param{object} 'pathname)
  310. \endcode
  311. \endcom%{pathnamep}
  312. %%% ========== PATHNAME-HOST
  313. %%% ========== PATHNAME-DEVICE
  314. %%% ========== PATHNAME-DIRECTORY
  315. %%% ========== PATHNAME-NAME
  316. %%% ========== PATHNAME-TYPE
  317. %%% ========== PATHNAME-VERSION
  318. \begincom{pathname-host, pathname-device, pathname-directory,
  319. pathname-name, pathname-type, pathname-version}\ftype{Function}
  320. \label Syntax::
  321. \issue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  322. \DefunWithValues pathname-host {pathname {\key} case} {host}
  323. \DefunWithValues pathname-device {pathname {\key} case} {device}
  324. \DefunWithValues pathname-directory {pathname {\key} case} {directory}
  325. \DefunWithValues pathname-name {pathname {\key} case} {name}
  326. \DefunWithValues pathname-type {pathname {\key} case} {type}
  327. \endissue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  328. \DefunWithValues pathname-version {pathname} {version}
  329. \label Arguments and Values::
  330. \issue{PATHNAME-STREAM}
  331. \param{pathname}---a \term{pathname designator}.
  332. \endissue{PATHNAME-STREAM}
  333. \issue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  334. \param{case}---one of \kwd{local} or \kwd{common}.
  335. \Default{\kwd{local}}
  336. \endissue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  337. \issue{PATHNAME-UNSPECIFIC-COMPONENT:NEW-TOKEN}
  338. \param{host}---a \term{valid pathname host}.
  339. \param{device}---a \term{valid pathname device}.
  340. \issue{PATHNAME-SUBDIRECTORY-LIST:NEW-REPRESENTATION}
  341. \param{directory}---a \term{valid pathname directory}.
  342. \endissue{PATHNAME-SUBDIRECTORY-LIST:NEW-REPRESENTATION}
  343. \param{name}---a \term{valid pathname name}.
  344. \param{type}---a \term{valid pathname type}.
  345. \param{version}---a \term{valid pathname version}.
  346. \endissue{PATHNAME-UNSPECIFIC-COMPONENT:NEW-TOKEN}
  347. \label Description::
  348. %% 23.1.2 30
  349. These functions return the components of \param{pathname}.
  350. If the \param{pathname} \term{designator} is a \term{pathname},
  351. it represents the name used to open the file. This may be, but is
  352. not required to be, the actual name of the file.
  353. \issue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  354. If \param{case} is supplied,
  355. it is treated as described in \secref\PathnameComponentCase.
  356. \endissue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  357. \label Examples::
  358. \issue{PATHNAME-WILD:NEW-FUNCTIONS}
  359. \issue{PATHNAME-SUBDIRECTORY-LIST:NEW-REPRESENTATION}
  360. \code
  361. (setq q (make-pathname :host "KATHY"
  362. :directory "CHAPMAN"
  363. :name "LOGIN" :type "COM"))
  364. \EV #P"KATHY::[CHAPMAN]LOGIN.COM"
  365. (pathname-host q) \EV "KATHY"
  366. (pathname-name q) \EV "LOGIN"
  367. (pathname-type q) \EV "COM"
  368. ;; Because namestrings are used, the results shown in the remaining
  369. ;; examples are not necessarily the only possible results. Mappings
  370. ;; from namestring representation to pathname representation are
  371. ;; dependent both on the file system involved and on the implementation
  372. ;; (since there may be several implementations which can manipulate the
  373. ;; the same file system, and those implementations are not constrained
  374. ;; to agree on all details). Consult the documentation for each
  375. ;; implementation for specific information on how namestrings are treated
  376. ;; that implementation.
  377. ;; VMS
  378. (pathname-directory (parse-namestring "[FOO.*.BAR]BAZ.LSP"))
  379. \EV (:ABSOLUTE "FOO" "BAR")
  380. (pathname-directory (parse-namestring "[FOO.*.BAR]BAZ.LSP") :case :common)
  381. \EV (:ABSOLUTE "FOO" "BAR")
  382. ;; Unix
  383. (pathname-directory "foo.l") \EV NIL
  384. (pathname-device "foo.l") \EV :UNSPECIFIC
  385. (pathname-name "foo.l") \EV "foo"
  386. (pathname-name "foo.l" :case :local) \EV "foo"
  387. (pathname-name "foo.l" :case :common) \EV "FOO"
  388. (pathname-type "foo.l") \EV "l"
  389. (pathname-type "foo.l" :case :local) \EV "l"
  390. (pathname-type "foo.l" :case :common) \EV "L"
  391. (pathname-type "foo") \EV :UNSPECIFIC
  392. (pathname-type "foo" :case :common) \EV :UNSPECIFIC
  393. (pathname-type "foo.") \EV ""
  394. (pathname-type "foo." :case :common) \EV ""
  395. (pathname-directory (parse-namestring "/foo/bar/baz.lisp") :case :local)
  396. \EV (:ABSOLUTE "foo" "bar")
  397. (pathname-directory (parse-namestring "/foo/bar/baz.lisp") :case :local)
  398. \EV (:ABSOLUTE "FOO" "BAR")
  399. (pathname-directory (parse-namestring "../baz.lisp"))
  400. \EV (:RELATIVE :UP)
  401. (PATHNAME-DIRECTORY (PARSE-NAMESTRING "/foo/BAR/../Mum/baz"))
  402. \EV (:ABSOLUTE "foo" "BAR" :UP "Mum")
  403. (PATHNAME-DIRECTORY (PARSE-NAMESTRING "/foo/BAR/../Mum/baz") :case :common)
  404. \EV (:ABSOLUTE "FOO" "bar" :UP "Mum")
  405. (PATHNAME-DIRECTORY (PARSE-NAMESTRING "/foo/*/bar/baz.l"))
  406. \EV (:ABSOLUTE "foo" :WILD "bar")
  407. (PATHNAME-DIRECTORY (PARSE-NAMESTRING "/foo/*/bar/baz.l") :case :common)
  408. \EV (:ABSOLUTE "FOO" :WILD "BAR")
  409. ;; Symbolics LMFS
  410. (pathname-directory (parse-namestring ">foo>**>bar>baz.lisp"))
  411. \EV (:ABSOLUTE "foo" :WILD-INFERIORS "bar")
  412. (pathname-directory (parse-namestring ">foo>*>bar>baz.lisp"))
  413. \EV (:ABSOLUTE "foo" :WILD "bar")
  414. (pathname-directory (parse-namestring ">foo>*>bar>baz.lisp") :case :common)
  415. \EV (:ABSOLUTE "FOO" :WILD "BAR")
  416. (pathname-device (parse-namestring ">foo>baz.lisp")) \EV :UNSPECIFIC
  417. \endcode
  418. \endissue{PATHNAME-SUBDIRECTORY-LIST:NEW-REPRESENTATION}
  419. \endissue{PATHNAME-WILD:NEW-FUNCTIONS}
  420. \label Affected By::
  421. The \term{implementation} and the host \term{file system}.
  422. \label Exceptional Situations::
  423. Should signal an error \oftype{type-error} if its first argument is not a \term{pathname}.
  424. \label See Also::
  425. \issue{PATHNAME-LOGICAL:ADD}
  426. \typeref{pathname},
  427. \typeref{logical-pathname},
  428. {\secref\FileSystemConcepts},
  429. \endissue{PATHNAME-LOGICAL:ADD}
  430. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  431. {\secref\PathnamesAsFilenames}
  432. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  433. \label Notes:\None.
  434. \endcom%{pathname-host, ...}
  435. %-------------------- Logical Pathnames --------------------
  436. %%% ========== LOAD-LOGICAL-PATHNAME-TRANSLATIONS
  437. \begincom{load-logical-pathname-translations}\ftype{Function}
  438. \issue{PATHNAME-LOGICAL:ADD}
  439. \label Syntax::
  440. \DefunWithValues load-logical-pathname-translations {host} {just-loaded}
  441. \label Arguments and Values::
  442. \param{host}---a \term{string}.
  443. \term{just-loaded}---a \term{generalized boolean}.
  444. \label Description::
  445. Searches for and loads the definition of a \term{logical host} named \param{host},
  446. if it is not already defined.
  447. The specific nature of the search is \term{implementation-defined}.
  448. If the \param{host} is already defined,
  449. no attempt to find or load a definition is attempted,
  450. and \term{false} is returned.
  451. If the \param{host} is not already defined,
  452. but a definition is successfully found and loaded,
  453. \term{true} is returned.
  454. Otherwise, an error is signaled.
  455. \label Examples::
  456. \code
  457. (translate-logical-pathname "hacks:weather;barometer.lisp.newest")
  458. \OUT Error: The logical host HACKS is not defined.
  459. (load-logical-pathname-translations "HACKS")
  460. \OUT ;; Loading SYS:SITE;HACKS.TRANSLATIONS
  461. \OUT ;; Loading done.
  462. \EV \term{true}
  463. (translate-logical-pathname "hacks:weather;barometer.lisp.newest")
  464. \EV #P"HELIUM:[SHARED.HACKS.WEATHER]BAROMETER.LSP;0"
  465. (load-logical-pathname-translations "HACKS")
  466. \EV \term{false}
  467. \endcode
  468. \label Affected By:\None.
  469. \label Exceptional Situations::
  470. If no definition is found, an error \oftype{error} is signaled.
  471. \label See Also::
  472. \typeref{logical-pathname}
  473. \label Notes::
  474. \term{Logical pathname} definitions will be created not just by
  475. \term{implementors} but also by \term{programmers}. As such,
  476. it is important that the search strategy be documented.
  477. For example, an \term{implementation} might define that the
  478. definition of a \param{host} is to be found in a file called
  479. ``\param{host}.translations'' in some specifically named directory.
  480. \endissue{PATHNAME-LOGICAL:ADD}
  481. \endcom%{load-logical-pathname-translations}
  482. %%% ========== LOGICAL-PATHNAME-TRANSLATIONS
  483. \begincom{logical-pathname-translations}\ftype{Accessor}
  484. \issue{PATHNAME-LOGICAL:ADD}
  485. \label Syntax::
  486. \DefunWithValues logical-pathname-translations {host} {translations}
  487. \Defsetf logical-pathname-translations {host} {new-translations}
  488. \label Arguments and Values::
  489. \param{host}--a \term{logical host designator}.
  490. \param{translations}, \param{new-translations}---a \term{list}.
  491. \label Description::
  492. Returns the host's \term{list} of translations.
  493. Each translation is a \term{list} of at least two elements:
  494. \i{from-wildcard} and \i{to-wildcard}. Any
  495. additional elements are \term{implementation-defined}.
  496. \i{From-wildcard} is a
  497. \term{logical pathname} whose host is \param{host}.
  498. \i{To-wildcard} is a \term{pathname}.
  499. \reviewer{Laddaga: Can this be a logical pathname?}
  500. \f{(setf (logical-pathname-translations \param{host}) \i{translations})} sets a
  501. \term{logical pathname} host's
  502. \term{list} of \i{translations}. If \param{host}
  503. is a \term{string} that has
  504. not been previously used as
  505. a \term{logical pathname} host, a new
  506. \term{logical pathname} host is defined;
  507. otherwise an existing host's translations are
  508. replaced. \term{logical pathname} host names are compared with \funref{string-equal}.
  509. When setting the translations list, each \i{from-wildcard}
  510. can be a \term{logical pathname} whose
  511. host is \param{host} or a \term{logical pathname} namestring
  512. parseable by \f{(parse-namestring \term{string} \i{host})},
  513. where \i{host}
  514. represents the appropriate \term{object} as defined
  515. by \funref{parse-namestring}. Each
  516. \i{to-wildcard} can be anything coercible to a
  517. \term{pathname} by
  518. \f{(pathname \i{to-wildcard})}.
  519. If \i{to-wildcard} coerces to a \term{logical pathname},
  520. \funref{translate-logical-pathname}
  521. will perform repeated translation steps when
  522. it uses it.
  523. \param{host} is either the host component of a
  524. \term{logical pathname} or a
  525. \term{string} that has been defined
  526. as a \term{logical pathname} host name by \macref{setf} of
  527. \funref{logical-pathname-translations}.
  528. \label Examples::
  529. \reviewer{Laddaga: Shouldn't there be some \f{*.*}'s in the list
  530. of translations for \f{PROG} below?}
  531. \code
  532. ;;;A very simple example of setting up a logical pathname host. No
  533. ;;;translations are necessary to get around file system restrictions, so
  534. ;;;all that is necessary is to specify the root of the physical directory
  535. ;;;tree that contains the logical file system.
  536. ;;;The namestring syntax on the right-hand side is implementation-dependent.
  537. (setf (logical-pathname-translations "foo")
  538. '(("**;*.*.*" "MY-LISPM:>library>foo>**>")))
  539. \smallbreak
  540. ;;;Sample use of that logical pathname. The return value
  541. ;;;is implementation-dependent.
  542. (translate-logical-pathname "foo:bar;baz;mum.quux.3")
  543. \EV #P"MY-LISPM:>library>foo>bar>baz>mum.quux.3"
  544. \medbreak
  545. ;;;A more complex example, dividing the files among two file servers
  546. ;;;and several different directories. This Unix doesn't support
  547. ;;;:WILD-INFERIORS in the directory, so each directory level must
  548. ;;;be translated individually. No file name or type translations
  549. ;;;are required except for .MAIL to .MBX.
  550. ;;;The namestring syntax on the right-hand side is implementation-dependent.
  551. (setf (logical-pathname-translations "prog")
  552. '(("RELEASED;*.*.*" "MY-UNIX:/sys/bin/my-prog/")
  553. ("RELEASED;*;*.*.*" "MY-UNIX:/sys/bin/my-prog/*/")
  554. ("EXPERIMENTAL;*.*.*" "MY-UNIX:/usr/Joe/development/prog/")
  555. ("EXPERIMENTAL;DOCUMENTATION;*.*.*"
  556. "MY-VAX:SYS$DISK:[JOE.DOC]")
  557. ("EXPERIMENTAL;*;*.*.*" "MY-UNIX:/usr/Joe/development/prog/*/")
  558. ("MAIL;**;*.MAIL" "MY-VAX:SYS$DISK:[JOE.MAIL.PROG...]*.MBX")))
  559. \smallbreak
  560. ;;;Sample use of that logical pathname. The return value
  561. ;;;is implementation-dependent.
  562. (translate-logical-pathname "prog:mail;save;ideas.mail.3")
  563. \EV #P"MY-VAX:SYS$DISK:[JOE.MAIL.PROG.SAVE]IDEAS.MBX.3"
  564. \medbreak
  565. ;;;Example translations for a program that uses three files main.lisp,
  566. ;;;auxiliary.lisp, and documentation.lisp. These translations might be
  567. ;;;supplied by a software supplier as examples.
  568. \smallbreak
  569. ;;;For Unix with long file names
  570. (setf (logical-pathname-translations "prog")
  571. '(("CODE;*.*.*" "/lib/prog/")))
  572. \smallbreak
  573. ;;;Sample use of that logical pathname. The return value
  574. ;;;is implementation-dependent.
  575. (translate-logical-pathname "prog:code;documentation.lisp")
  576. \EV #P"/lib/prog/documentation.lisp"
  577. \smallbreak
  578. ;;;For Unix with 14-character file names, using .lisp as the type
  579. (setf (logical-pathname-translations "prog")
  580. '(("CODE;DOCUMENTATION.*.*" "/lib/prog/docum.*")
  581. ("CODE;*.*.*" "/lib/prog/")))
  582. ;;;Sample use of that logical pathname. The return value
  583. ;;;is implementation-dependent.
  584. (translate-logical-pathname "prog:code;documentation.lisp")
  585. \EV #P"/lib/prog/docum.lisp"
  586. \medbreak
  587. ;;;For Unix with 14-character file names, using .l as the type
  588. ;;;The second translation shortens the compiled file type to .b
  589. (setf (logical-pathname-translations "prog")
  590. `(("**;*.LISP.*" ,(logical-pathname "PROG:**;*.L.*"))
  591. (,(compile-file-pathname (logical-pathname "PROG:**;*.LISP.*"))
  592. ,(logical-pathname "PROG:**;*.B.*"))
  593. ("CODE;DOCUMENTATION.*.*" "/lib/prog/documentatio.*")
  594. ("CODE;*.*.*" "/lib/prog/")))
  595. \smallbreak
  596. ;;;Sample use of that logical pathname. The return value
  597. ;;;is implementation-dependent.
  598. (translate-logical-pathname "prog:code;documentation.lisp")
  599. \EV #P"/lib/prog/documentatio.l"
  600. \medbreak
  601. ;;;For a Cray with 6 character names and no directories, types, or versions.
  602. (setf (logical-pathname-translations "prog")
  603. (let ((l '(("MAIN" "PGMN")
  604. ("AUXILIARY" "PGAUX")
  605. ("DOCUMENTATION" "PGDOC")))
  606. (logpath (logical-pathname "prog:code;"))
  607. (phypath (pathname "XXX")))
  608. (append
  609. ;; Translations for source files
  610. (mapcar #'(lambda (x)
  611. (let ((log (first x))
  612. (phy (second x)))
  613. (list (make-pathname :name log
  614. :type "LISP"
  615. :version :wild
  616. :defaults logpath)
  617. (make-pathname :name phy
  618. :defaults phypath))))
  619. l)
  620. ;; Translations for compiled files
  621. (mapcar #'(lambda (x)
  622. (let* ((log (first x))
  623. (phy (second x))
  624. (com (compile-file-pathname
  625. (make-pathname :name log
  626. :type "LISP"
  627. :version :wild
  628. :defaults logpath))))
  629. (setq phy (concatenate 'string phy "B"))
  630. (list com
  631. (make-pathname :name phy
  632. :defaults phypath))))
  633. l))))
  634. ;;;Sample use of that logical pathname. The return value
  635. ;;;is implementation-dependent.
  636. (translate-logical-pathname "prog:code;documentation.lisp")
  637. \EV #P"PGDOC"
  638. \endcode
  639. \label Affected By:\None.
  640. \label Exceptional Situations::
  641. If \param{host} is incorrectly supplied,
  642. an error \oftype{type-error} is signaled.
  643. \label See Also::
  644. \typeref{logical-pathname},
  645. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  646. {\secref\PathnamesAsFilenames}
  647. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  648. \label Notes::
  649. Implementations can define additional \term{functions}
  650. that operate on \term{logical pathname} hosts,
  651. for example to specify additional translation rules or options.
  652. \endissue{PATHNAME-LOGICAL:ADD}
  653. \endcom%{logical-pathname-translations}
  654. %%% ========== LOGICAL-PATHNAME
  655. \begincom{logical-pathname}\ftype{Function}
  656. \issue{PATHNAME-LOGICAL:ADD}
  657. \label Syntax::
  658. \DefunWithValues logical-pathname {pathspec} {logical-pathname}
  659. \label Arguments and Values::
  660. \param{pathspec}---a \term{logical pathname},
  661. a \term{logical pathname} \term{namestring},
  662. or a \term{stream}.
  663. \param{logical-pathname}---a \term{logical pathname}.
  664. \label Description::
  665. \funref{logical-pathname} converts \param{pathspec} to a
  666. \term{logical pathname} and returns the new \term{logical pathname}.
  667. If \param{pathspec} is a \term{logical pathname} \term{namestring},
  668. it should contain a host component and its following \term{colon}.
  669. If \param{pathspec} is a \term{stream}, it should be one
  670. for which \funref{pathname} returns a \term{logical pathname}.
  671. \issue{CLOSED-STREAM-FUNCTIONS:ALLOW-INQUIRY}
  672. If \param{pathspec} is a \term{stream}, the \term{stream} can be either open or closed.
  673. \funref{logical-pathname} returns the same \term{logical pathname} after a
  674. file is closed as it did when the file was open.
  675. \endissue{CLOSED-STREAM-FUNCTIONS:ALLOW-INQUIRY}
  676. \issue{PATHNAME-STREAM}
  677. It is an error if \param{pathspec} is a \term{stream} that is
  678. created with
  679. \funref{make-two-way-stream},
  680. \funref{make-echo-stream},
  681. \funref{make-broadcast-stream},
  682. \funref{make-concatenated-stream},
  683. \funref{make-string-input-stream},
  684. or
  685. \funref{make-string-output-stream}.
  686. \endissue{PATHNAME-STREAM}
  687. \label Examples:\None.
  688. \label Affected By:\None.
  689. \label Exceptional Situations::
  690. Signals an error \oftype{type-error} if \param{pathspec} isn't supplied correctly.
  691. \label See Also::
  692. \typeref{logical-pathname},
  693. \funref{translate-logical-pathname},
  694. {\secref\LogicalPathnames}
  695. \label Notes:\None.
  696. \endissue{PATHNAME-LOGICAL:ADD}
  697. \endcom%{logical-pathname}
  698. %-------------------- Pathname Parsing --------------------
  699. %%% ========== DEFAULT-PATHNAME-DEFAULTS
  700. \begincom{*default-pathname-defaults*}\ftype{Variable}
  701. \label Value Type::
  702. a \term{pathname} \term{object}.
  703. \label Initial Value::
  704. %I added this first little phrase. -kmp 12-Jan-91
  705. An \term{implementation-dependent} \term{pathname},
  706. typically in the working directory that was current when \clisp\ was started up.
  707. \label Description::
  708. %% 23.1.2 26
  709. a \term{pathname}, used as the default whenever a \term{function}
  710. needs a default \term{pathname} and one is not supplied.
  711. \label Examples::
  712. \code
  713. ;; This example illustrates a possible usage for a hypothetical Lisp running on a
  714. ;; DEC TOPS-20 file system. Since pathname conventions vary between Lisp
  715. ;; implementations and host file system types, it is not possible to provide a
  716. ;; general-purpose, conforming example.
  717. *default-pathname-defaults* \EV #P"PS:<FRED>"
  718. (merge-pathnames (make-pathname :name "CALENDAR"))
  719. \EV #P"PS:<FRED>CALENDAR"
  720. (let ((*default-pathname-defaults* (pathname "<MARY>")))
  721. (merge-pathnames (make-pathname :name "CALENDAR")))
  722. \EV #P"<MARY>CALENDAR"
  723. \endcode
  724. \label Affected By::
  725. The \term{implementation}.
  726. \label See Also:\None.
  727. \label Notes:\None.
  728. \endcom%{*default-pathname-defaults*}
  729. %-------------------- Pathname Namestrings --------------------
  730. %%% ========== NAMESTRING
  731. %%% ========== FILE-NAMESTRING
  732. %%% ========== DIRECTORY-NAMESTRING
  733. %%% ========== HOST-NAMESTRING
  734. %%% ========== ENOUGH-NAMESTRING
  735. \begincom{namestring, file-namestring, directory-namestring,
  736. host-namestring, enough-namestring}\ftype{Function}
  737. \label Syntax::
  738. \DefunWithValues namestring {pathname} {namestring}
  739. \DefunWithValues file-namestring {pathname} {namestring}
  740. \DefunWithValues directory-namestring {pathname} {namestring}
  741. \DefunWithValues host-namestring {pathname} {namestring}
  742. \DefunWithValues enough-namestring {pathname {\opt} defaults} {namestring}
  743. \label Arguments and Values::
  744. \issue{PATHNAME-STREAM}
  745. \param{pathname}---a \term{pathname designator}.
  746. \endissue{PATHNAME-STREAM}
  747. \issue{PATHNAME-SYMBOL}
  748. \param{defaults}---a \term{pathname designator}.
  749. \endissue{PATHNAME-SYMBOL}
  750. \Default{\thevalueof{*default-pathname-defaults*}}
  751. \param{namestring}---a \term{string} or \nil.
  752. \editornote{KMP: Under what circumstances can NIL be returned??}%!!!
  753. \label Description::
  754. \issue{PATHNAME-SYMBOL}
  755. % Reference to conversion of symbol to a pathname removed.
  756. \endissue{PATHNAME-SYMBOL}
  757. These functions convert \param{pathname} into a namestring.
  758. %% 23.1.2 31
  759. The name represented by \param{pathname} is returned as a \term{namestring}
  760. in an \term{implementation-dependent} canonical form.
  761. %% 23.1.2 33
  762. \funref{namestring} returns the full form of \param{pathname}.
  763. \funref{file-namestring} returns just the name, type, and version
  764. components of \param{pathname}.
  765. \funref{directory-namestring} returns the directory name portion.
  766. \funref{host-namestring} returns the host name.
  767. %% 23.1.2 34
  768. \funref{enough-namestring} returns an abbreviated namestring
  769. that is just sufficient to identify the file named by \param{pathname}
  770. when considered relative to the \param{defaults}.
  771. It is required that
  772. \code
  773. (merge-pathnames (enough-namestring pathname defaults) defaults)
  774. \EQ (merge-pathnames (parse-namestring pathname nil defaults) defaults)
  775. \endcode
  776. in all cases, and the result of \funref{enough-namestring} is
  777. the shortest reasonable \term{string} that will satisfy this criterion.
  778. It is not necessarily possible to construct a valid \term{namestring}
  779. by concatenating some of the three shorter \term{namestrings} in some order.
  780. \label Examples::
  781. %!!! This example needs to use real filenames instead of "\i{directory-name}", etc.
  782. \code
  783. (namestring "getty")
  784. \EV "getty"
  785. (setq q (make-pathname :host "kathy"
  786. :directory
  787. (pathname-directory *default-pathname-defaults*)
  788. :name "getty"))
  789. \EV #S(PATHNAME :HOST "kathy" :DEVICE NIL :DIRECTORY \i{directory-name}
  790. :NAME "getty" :TYPE NIL :VERSION NIL)
  791. (file-namestring q) \EV "getty"
  792. (directory-namestring q) \EV \i{directory-name}
  793. (host-namestring q) \EV "kathy"
  794. \endcode
  795. \issue{PATHNAME-WILD:NEW-FUNCTIONS}
  796. \code
  797. ;;;Using Unix syntax and the wildcard conventions used by the
  798. ;;;particular version of Unix on which this example was created:
  799. (namestring
  800. (translate-pathname "/usr/dmr/hacks/frob.l"
  801. "/usr/d*/hacks/*.l"
  802. "/usr/d*/backup/hacks/backup-*.*"))
  803. \EV "/usr/dmr/backup/hacks/backup-frob.l"
  804. (namestring
  805. (translate-pathname "/usr/dmr/hacks/frob.l"
  806. "/usr/d*/hacks/fr*.l"
  807. "/usr/d*/backup/hacks/backup-*.*"))
  808. \EV "/usr/dmr/backup/hacks/backup-ob.l"
  809. ;;;This is similar to the above example but uses two different hosts,
  810. ;;;U: which is a Unix and V: which is a VMS. Note the translation
  811. ;;;of file type and alphabetic case conventions.
  812. (namestring
  813. (translate-pathname "U:/usr/dmr/hacks/frob.l"
  814. "U:/usr/d*/hacks/*.l"
  815. "V:SYS$DISK:[D*.BACKUP.HACKS]BACKUP-*.*"))
  816. \EV "V:SYS$DISK:[DMR.BACKUP.HACKS]BACKUP-FROB.LSP"
  817. (namestring
  818. (translate-pathname "U:/usr/dmr/hacks/frob.l"
  819. "U:/usr/d*/hacks/fr*.l"
  820. "V:SYS$DISK:[D*.BACKUP.HACKS]BACKUP-*.*"))
  821. \EV "V:SYS$DISK:[DMR.BACKUP.HACKS]BACKUP-OB.LSP"
  822. \endcode
  823. \endissue{PATHNAME-WILD:NEW-FUNCTIONS}
  824. \label Affected By:\None.
  825. \label Exceptional Situations:\None.
  826. \label See Also::
  827. \issue{PATHNAME-LOGICAL:ADD}
  828. \funref{truename},
  829. \funref{merge-pathnames},
  830. \typeref{pathname},
  831. \typeref{logical-pathname},
  832. {\secref\FileSystemConcepts},
  833. \endissue{PATHNAME-LOGICAL:ADD}
  834. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  835. {\secref\PathnamesAsFilenames}
  836. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  837. \label Notes:\None.
  838. \endcom%{namestring, ...}
  839. %%% ========== PARSE-NAMESTRING
  840. \begincom{parse-namestring}\ftype{Function}
  841. \label Syntax::
  842. \DefunWithValuesNewline parse-namestring
  843. {thing {\opt} host default-pathname {\key} start end junk-allowed}
  844. {pathname, position}
  845. \label Arguments and Values::
  846. \issue{PATHNAME-SYMBOL}
  847. \issue{PATHNAME-LOGICAL:ADD}
  848. \param{thing}---a \term{string},
  849. a \term{pathname},
  850. or a \term{stream associated with a file}.
  851. %% This isn't quite right. The start/end thing puts a wrinkle in things. -kmp 29-Aug-93
  852. %\term{pathname designator}
  853. \endissue{PATHNAME-LOGICAL:ADD}
  854. \endissue{PATHNAME-SYMBOL}
  855. \issue{PATHNAME-LOGICAL:ADD}
  856. \issue{PATHNAME-UNSPECIFIC-COMPONENT:NEW-TOKEN}
  857. %% Added NIL here because the Description seemed to permit it. -kmp 29-Aug-93
  858. \param{host}---a \term{valid pathname host}, a \term{logical host}, or \nil.
  859. \endissue{PATHNAME-UNSPECIFIC-COMPONENT:NEW-TOKEN}
  860. \endissue{PATHNAME-LOGICAL:ADD}
  861. \param{default-pathname}---a \term{pathname designator}.
  862. \Default{\thevalueof{*default-pathname-defaults*}}
  863. %% This should go without saying!! -kmp 29-Aug-93
  864. %It is an error if optional arguments do not accompany keyword arguments.
  865. \issue{SUBSEQ-OUT-OF-BOUNDS}
  866. \issue{RANGE-OF-START-AND-END-PARAMETERS:INTEGER-AND-INTEGER-NIL}
  867. \param{start}, \param{end}---\term{bounding index designators} of \param{thing}.
  868. \Defaults{\param{start} and \param{end}}{\f{0} and \nil}
  869. \endissue{RANGE-OF-START-AND-END-PARAMETERS:INTEGER-AND-INTEGER-NIL}
  870. \endissue{SUBSEQ-OUT-OF-BOUNDS}
  871. \param{junk-allowed}---a \term{generalized boolean}.
  872. \Default{\term{false}}
  873. \param{pathname}---a \term{pathname}, or \nil.
  874. \param{position}---a \term{bounding index designator} for \param{thing}.
  875. \label Description::
  876. %% 23.1.2 9
  877. %% 23.1.2 10
  878. Converts \param{thing} into a \term{pathname}.
  879. The \param{host} supplies a host name with respect to which the parsing occurs.
  880. %% Removed per X3J13. -kmp 05-Oct-93
  881. % If \param{host} is \nil,
  882. % then the host name is extracted from \param{default-pathname}
  883. % and used to determine the syntax convention.
  884. \issue{PATHNAME-STREAM}
  885. If \param{thing} is a \term{stream associated with a file},
  886. processing proceeds as if the \term{pathname} used to open that \term{file}
  887. had been supplied instead.
  888. \endissue{PATHNAME-STREAM}
  889. If \param{thing} is a \term{pathname},
  890. the \param{host} and the host component of \param{thing} are compared.
  891. %% 23.1.2 15
  892. %If \param{thing} is not a \term{string}, then \param{start} is returned as the second value.
  893. If they match,
  894. two values are immediately returned: \param{thing} and \param{start};
  895. otherwise (if they do not match), an error is signaled.
  896. \issue{PATHNAME-SYMBOL}
  897. % If \param{thing} is a \term{symbol}, the print name is used.
  898. \endissue{PATHNAME-SYMBOL}
  899. %% 23.1.2 11
  900. Otherwise (if \param{thing} is a \term{string}),
  901. \funref{parse-namestring} parses the name of a \term{file} within
  902. the substring of \param{thing} bounded by \param{start} and \param{end}.
  903. \issue{PATHNAME-LOGICAL:ADD}
  904. \issue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  905. %% Replaced (again) per X3J13. -kmp 05-Oct-93
  906. % \param{thing} is recognized as a \term{logical pathname} \term{namestring}
  907. % when \param{host} is a \term{logical host}
  908. % (or a \term{string} that names a defined \term{logical host}),
  909. % \param{default-pathname} is a \term{logical pathname},
  910. % %% Per X3J13. -kmp 05-Oct-93
  911. % % or the substring begins with the name of a defined \term{logical host}
  912. % % followed by a \term{colon}.
  913. % or \param{host} is unsupplied and \param{thing} is a \term{string}
  914. % that is a syntactically valid \term{logical pathname} \term{namestring}
  915. % containing an explicit host.
  916. If \param{thing} is a \term{string} then
  917. %% I added this. -kmp 05-Oct-93
  918. % it
  919. the substring of \param{thing} \term{bounded} by \param{start} and \param{end}
  920. is parsed into a \term{pathname}
  921. as follows:
  922. \beginlist
  923. \itemitem{\bull}
  924. If \param{host} is a \term{logical host} then \param{thing} is parsed
  925. as a \term{logical pathname} \term{namestring}
  926. %% I added this. -kmp 05-Oct-93
  927. on the \param{host}.
  928. \itemitem{\bull}
  929. If \param{host} is \nil\ and \param{thing} is a syntactically valid
  930. \term{logical pathname} \term{namestring} containing an explicit host,
  931. then it is parsed as a \term{logical pathname} \term{namestring}.
  932. \itemitem{\bull}
  933. If \param{host} is \nil,
  934. \param{default-pathname} is a \term{logical pathname},
  935. and \param{thing} is a syntactically valid \term{logical pathname} \term{namestring}
  936. without an explicit host,
  937. then it is parsed as a \term{logical pathname} \term{namestring}
  938. %% Wording simplified by me. -kmp 05-Oct-93
  939. % with the host from \param{default-pathname}
  940. % used as the host for the resulting \term{pathname}.
  941. on the host that is the host component of \param{default-pathname}.
  942. \itemitem{\bull}
  943. Otherwise, the parsing of \param{thing} is \term{implementation-defined}.
  944. \endlist
  945. In the first
  946. %% Changed to match wording voted by X3J13 above. -kmp 05-Oct-93
  947. %two
  948. of these
  949. %% Don't bother trying to count. -kmp 05-Oct-93
  950. %three
  951. cases,
  952. the host portion of the \term{logical pathname} namestring
  953. and its following \term{colon} are optional.
  954. % Whether a host argument is logical if it is a \term{string}
  955. % that is \term{string equal} to a \term{logical pathname} host name is
  956. % \term{implementation-defined}.
  957. \endissue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  958. \endissue{PATHNAME-LOGICAL:ADD}
  959. If the host portion of the namestring and \param{host}
  960. are both present and do not match,
  961. an error is signaled.
  962. %% 23.1.2 12
  963. If \param{junk-allowed} is \term{true},
  964. then the \term{primary value} is the \term{pathname} parsed
  965. or, if no syntactically correct \term{pathname} was seen, \nil.
  966. %% 23.1.2 13
  967. If \param{junk-allowed} is \term{false},
  968. then the entire substring is scanned,
  969. and the \term{primary value} is the \term{pathname} parsed.
  970. %% 23.1.2 14
  971. In either case, the \term{secondary value}
  972. is the index into \param{thing} of the delimiter that terminated the parse,
  973. or the index beyond the substring if the parse terminated at the end of the substring
  974. (as will always be the case if \param{junk-allowed} is \term{false}).
  975. %% 23.1.2 16
  976. Parsing a \term{null} \term{string} always succeeds,
  977. producing a \term{pathname} with all components (except the host) equal to \nil.
  978. %% 23.1.2 18
  979. If \param{thing} contains an explicit host name and no explicit device name,
  980. then it is \term{implementation-defined} whether \funref{parse-namestring}
  981. will supply the standard default device for that host as the device component
  982. of the resulting \term{pathname}.
  983. \label Examples::
  984. \issue{PATHNAME-PRINT-READ:SHARPSIGN-P}
  985. \code
  986. (setq q (parse-namestring "test"))
  987. \EV #S(PATHNAME :HOST NIL :DEVICE NIL :DIRECTORY NIL :NAME "test"
  988. :TYPE NIL :VERSION NIL)
  989. (pathnamep q) \EV \term{true}
  990. (parse-namestring "test")
  991. \EV #S(PATHNAME :HOST NIL :DEVICE NIL :DIRECTORY NIL :NAME "test"
  992. :TYPE NIL :VERSION NIL), 4
  993. (setq s (open \i{xxx})) \EV #<Input File Stream...>
  994. (parse-namestring s)
  995. \EV #S(PATHNAME :HOST NIL :DEVICE NIL :DIRECTORY NIL :NAME \i{xxx}
  996. :TYPE NIL :VERSION NIL), 0
  997. (parse-namestring "test" nil nil :start 2 :end 4 )
  998. \EV #S(PATHNAME ...), 15
  999. (parse-namestring "foo.lisp")
  1000. \EV #P"foo.lisp"
  1001. \endcode
  1002. \endissue{PATHNAME-PRINT-READ:SHARPSIGN-P}
  1003. \label Affected By:\None.
  1004. \label Exceptional Situations::
  1005. If \param{junk-allowed} is \term{false},
  1006. an error \oftype{parse-error} is signaled if \param{thing}
  1007. does not consist entirely of the representation of a \term{pathname},
  1008. possibly surrounded on either side by \term{whitespace}\meaning{1} characters if that is
  1009. appropriate to the cultural conventions of the implementation.
  1010. %% 23.1.2 17
  1011. If \param{host} is supplied and not \nil,
  1012. and \param{thing} contains a manifest host name,
  1013. an error \oftype{error} is signaled if the hosts do not match.
  1014. \issue{PATHNAME-LOGICAL:ADD}
  1015. If \param{thing} is a \term{logical pathname} namestring
  1016. and if the host portion of the namestring and \param{host}
  1017. are both present and do not match,
  1018. an error \oftype{error} is signaled.
  1019. \endissue{PATHNAME-LOGICAL:ADD}
  1020. %% This is implied by stream associated with a file. -kmp 29-Aug-93
  1021. % \issue{PATHNAME-STREAM}
  1022. % It is an error if \param{thing} is a \term{stream} that is
  1023. % created with \funref{make-two-way-stream},
  1024. % \funref{make-echo-stream},
  1025. % \funref{make-broadcast-stream},
  1026. % \funref{make-concatenated-stream},
  1027. % \funref{make-string-input-stream},
  1028. % \funref{make-string-output-stream}.
  1029. % \endissue{PATHNAME-STREAM}
  1030. \label See Also::
  1031. \issue{PATHNAME-LOGICAL:ADD}
  1032. \typeref{pathname},
  1033. \typeref{logical-pathname},
  1034. {\secref\FileSystemConcepts},
  1035. \endissue{PATHNAME-LOGICAL:ADD}
  1036. {\secref\UnspecificComponent},
  1037. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1038. {\secref\PathnamesAsFilenames}
  1039. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1040. \label Notes:\None.
  1041. \endcom%{parse-namestring}
  1042. %-------------------- Pathname Matching --------------------
  1043. %%% ========== WILD-PATHNAME-P
  1044. \begincom{wild-pathname-p}\ftype{Function}
  1045. \issue{PATHNAME-WILD:NEW-FUNCTIONS}
  1046. \label Syntax::
  1047. \DefunWithValues wild-pathname-p {pathname {\opt} field-key} {generalized-boolean}
  1048. \label Arguments and Values::
  1049. \issue{PATHNAME-STREAM}
  1050. \param{pathname}---a \term{pathname designator}.
  1051. \endissue{PATHNAME-STREAM}
  1052. \param{Field-key}---one of \kwd{host},
  1053. \kwd{device}
  1054. \kwd{directory},
  1055. \kwd{name},
  1056. \kwd{type},
  1057. \kwd{version},
  1058. or \nil.
  1059. \param{generalized-boolean}---a \term{generalized boolean}.
  1060. \label Description::
  1061. \funref{wild-pathname-p} tests \param{pathname} for the presence of wildcard components.
  1062. If \param{pathname} is a \term{pathname} (as returned by \funref{pathname})
  1063. it represents the name used to open the file. This may be, but is
  1064. not required to be, the actual name of the file.
  1065. If \param{field-key} is not supplied or \nil, \funref{wild-pathname-p}
  1066. returns true if \param{pathname} has any wildcard components, \nil\
  1067. if \param{pathname} has none.
  1068. If \param{field-key} is \term{non-nil}, \funref{wild-pathname-p}
  1069. returns true if the indicated component of \param{pathname} is a wildcard,
  1070. \nil\ if the component is not a wildcard.
  1071. \label Examples::
  1072. \code
  1073. ;;;The following examples are not portable. They are written to run
  1074. ;;;with particular file systems and particular wildcard conventions.
  1075. ;;;Other implementations will behave differently. These examples are
  1076. ;;;intended to be illustrative, not to be prescriptive.
  1077. (wild-pathname-p (make-pathname :name :wild)) \EV \term{true}
  1078. (wild-pathname-p (make-pathname :name :wild) :name) \EV \term{true}
  1079. (wild-pathname-p (make-pathname :name :wild) :type) \EV \term{false}
  1080. (wild-pathname-p (pathname "s:>foo>**>")) \EV \term{true} ;Lispm
  1081. (wild-pathname-p (pathname :name "F*O")) \EV \term{true} ;Most places
  1082. \endcode
  1083. \label Affected By:\None.
  1084. \label Exceptional Situations::
  1085. If \param{pathname} is not a \term{pathname}, a \term{string},
  1086. or a \term{stream associated with a file} an error \oftype{type-error} is signaled.
  1087. \label See Also::
  1088. \issue{PATHNAME-LOGICAL:ADD}
  1089. \typeref{pathname},
  1090. \typeref{logical-pathname},
  1091. {\secref\FileSystemConcepts},
  1092. \endissue{PATHNAME-LOGICAL:ADD}
  1093. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1094. {\secref\PathnamesAsFilenames}
  1095. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1096. \label Notes::
  1097. Not all implementations support wildcards in all fields.
  1098. \Seesection\WildComponents\ and \secref\WildcardRestrictions.
  1099. \endissue{PATHNAME-WILD:NEW-FUNCTIONS}
  1100. \endcom%{wild-pathname-p}
  1101. %%% ========== PATHNAME-MATCH-P
  1102. \begincom{pathname-match-p}\ftype{Function}
  1103. \issue{PATHNAME-WILD:NEW-FUNCTIONS}
  1104. \label Syntax::
  1105. \DefunWithValues pathname-match-p {pathname wildcard} {generalized-boolean}
  1106. \label Arguments and Values::
  1107. \issue{PATHNAME-STREAM}
  1108. \param{pathname}---a \term{pathname designator}.
  1109. \param{wildcard}---a \term{designator} for a \term{wild} \term{pathname}.
  1110. \endissue{PATHNAME-STREAM}
  1111. \param{generalized-boolean}---a \term{generalized boolean}.
  1112. \label Description::
  1113. \funref{pathname-match-p} returns true if
  1114. \param{pathname} matches \param{wildcard}, otherwise \nil. The
  1115. matching rules are \term{implementation-defined} but should be consistent with
  1116. \funref{directory}. Missing components of \param{wildcard} default to \kwd{wild}.
  1117. It is valid for \param{pathname} to be a wild \term{pathname};
  1118. a wildcard field in \param{pathname} only matches a
  1119. wildcard field in \param{wildcard} (\ie
  1120. \funref{pathname-match-p} is not commutative).
  1121. It is valid for \param{wildcard} to be a non-wild \term{pathname}.
  1122. \label Examples:\None.
  1123. \label Affected By:\None.
  1124. \label Exceptional Situations::
  1125. If \param{pathname} or \param{wildcard} is not a \term{pathname}, \term{string},
  1126. or \term{stream associated with a file} an error \oftype{type-error} is signaled.
  1127. \label See Also::
  1128. \issue{PATHNAME-LOGICAL:ADD}
  1129. \funref{directory},
  1130. \typeref{pathname},
  1131. \typeref{logical-pathname},
  1132. {\secref\FileSystemConcepts},
  1133. \endissue{PATHNAME-LOGICAL:ADD}
  1134. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1135. {\secref\PathnamesAsFilenames}
  1136. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1137. \label Notes:\None.
  1138. \endissue{PATHNAME-WILD:NEW-FUNCTIONS}
  1139. \endcom%{pathname-match-p}
  1140. %%% ========== TRANSLATE-LOGICAL-PATHNAME
  1141. \begincom{translate-logical-pathname}\ftype{Function}
  1142. \issue{PATHNAME-LOGICAL:ADD}
  1143. \label Syntax::
  1144. \DefunWithValues translate-logical-pathname {pathname {\key}} {physical-pathname}
  1145. \label Arguments and Values::
  1146. \param{pathname}---a \term{pathname designator},
  1147. or a \term{logical pathname} \term{namestring}.
  1148. \param{physical-pathname}---a \term{physical pathname}.
  1149. \label Description::
  1150. Translates \param{pathname} to a \term{physical pathname}, which it returns.
  1151. \issue{CLOSED-STREAM-FUNCTIONS:ALLOW-INQUIRY}
  1152. If \param{pathname} is a \term{stream}, the
  1153. \term{stream} can be either open or closed.
  1154. \funref{translate-logical-pathname} returns the same
  1155. physical pathname after a
  1156. file is closed as it did when the file was open.
  1157. \endissue{CLOSED-STREAM-FUNCTIONS:ALLOW-INQUIRY}
  1158. \issue{PATHNAME-STREAM}
  1159. It is an error if \param{pathname} is a \term{stream} that is
  1160. created with \funref{make-two-way-stream},
  1161. \funref{make-echo-stream},
  1162. \funref{make-broadcast-stream},
  1163. \funref{make-concatenated-stream}, \funref{make-string-input-stream},
  1164. \funref{make-string-output-stream}.
  1165. \endissue{PATHNAME-STREAM}
  1166. If \param{pathname} is a \term{logical pathname} namestring,
  1167. the host portion of the
  1168. \term{logical pathname} namestring and its following \term{colon} are required.
  1169. \param{Pathname} is first coerced to a \term{pathname}.
  1170. If the coerced \param{pathname} is a physical pathname, it is returned.
  1171. If the coerced \param{pathname} is a \term{logical pathname},
  1172. the first matching translation (according to \funref{pathname-match-p})
  1173. of the \term{logical pathname} host is applied, as if by calling
  1174. \funref{translate-pathname}. If the result is
  1175. a \term{logical pathname}, this process is repeated.
  1176. When the result is
  1177. finally a physical pathname, it is returned.
  1178. If no translation matches, an error
  1179. is signaled.
  1180. \funref{translate-logical-pathname} might perform additional translations,
  1181. typically to provide translation of file types to local naming
  1182. conventions, to accomodate physical file systems with limited length
  1183. names, or to deal with special character requirements such as
  1184. translating hyphens to underscores or uppercase letters to lowercase.
  1185. Any such additional translations are \term{implementation-defined}. Some
  1186. implementations do no additional translations.
  1187. There are no specified keyword arguments for
  1188. \funref{translate-logical-pathname},
  1189. but implementations are permitted to extend
  1190. it by adding keyword arguments.
  1191. %The following was deleted because part 2 of EXTRA-RETURN-VALUES didn't
  1192. %pass.
  1193. %There is one specified return value
  1194. % from TRANSLATE-LOGICAL-PATHNAME; implementations are permitted to
  1195. % extend it by returning additional values.
  1196. \label Examples::
  1197. See \funref{logical-pathname-translations}.
  1198. \label Affected By:\None.%!!! Not likely.
  1199. \label Exceptional Situations::
  1200. If \param{pathname} is incorrectly supplied, an error \oftype{type-error} is signaled.
  1201. If no translation matches, an error \oftype{file-error} is signaled.
  1202. \editornote{KMP: Is file-error really right, or should it be pathname-error?}
  1203. \label See Also::
  1204. \funref{logical-pathname},
  1205. \funref{logical-pathname-translations},
  1206. \typeref{logical-pathname},
  1207. {\secref\FileSystemConcepts},
  1208. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1209. {\secref\PathnamesAsFilenames}
  1210. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1211. \label Notes:\None.
  1212. \endissue{PATHNAME-LOGICAL:ADD}
  1213. \endcom%{translate-logical-pathname}
  1214. %%% ========== TRANSLATE-PATHNAME
  1215. \begincom{translate-pathname}\ftype{Function}
  1216. \issue{PATHNAME-WILD:NEW-FUNCTIONS}
  1217. \label Syntax::
  1218. \DefunWithValuesNewline translate-pathname
  1219. {source from-wildcard to-wildcard {\key}}
  1220. {translated-pathname}
  1221. \label Arguments and Values::
  1222. \param{source}---a \term{pathname designator}.
  1223. \param{from-wildcard}---a \term{pathname designator}.
  1224. \param{to-wildcard}---a \term{pathname designator}.
  1225. \param{translated-pathname}---a \term{pathname}.
  1226. \label Description::
  1227. \funref{translate-pathname} translates \param{source}
  1228. (that matches \param{from-wildcard}) into a corresponding \term{pathname}
  1229. that matches \param{to-wildcard}, and returns the corresponding \term{pathname}.
  1230. The resulting \term{pathname} is \param{to-wildcard} with each wildcard or missing
  1231. field replaced by a portion of \param{source}. A ``wildcard field'' is a
  1232. \term{pathname} component with a value of \kwd{wild}, a \kwd{wild} element of a
  1233. \term{list}-valued directory component, or an \term{implementation-defined} portion
  1234. of a component, such as the \f{"*"} in the complex wildcard string
  1235. \f{"foo*bar"} that some implementations support. An implementation that
  1236. adds other wildcard features, such as regular expressions, must define
  1237. how \funref{translate-pathname} extends to those features.
  1238. A ``missing field'' is a \term{pathname} component with a value of \nil.
  1239. The portion of \param{source}
  1240. that is copied into the resulting \term{pathname} is
  1241. \term{implementation-defined}. Typically
  1242. it is determined by the user interface conventions
  1243. of the file systems involved. Usually it is the portion of \param{source}
  1244. that matches a wildcard field of
  1245. \param{from-wildcard} that is in the same
  1246. position as the wildcard or missing field of
  1247. \param{to-wildcard}. If there
  1248. is no wildcard field in
  1249. \param{from-wildcard} at that position, then usually
  1250. it is the entire corresponding
  1251. \term{pathname} component of \param{source}, or in
  1252. the case of a
  1253. \term{list}-valued directory component, the entire corresponding
  1254. \term{list} element.
  1255. During the copying of a portion of \param{source} into
  1256. the resulting \term{pathname}, additional
  1257. \term{implementation-defined} translations of \term{case} or file naming
  1258. conventions might occur, especially when
  1259. \param{from-wildcard} and
  1260. \param{to-wildcard} are for different hosts.
  1261. It is valid for
  1262. \param{source} to be a wild
  1263. \term{pathname}; in general this will produce a wild
  1264. result. It
  1265. is valid for \param{from-wildcard} and/or \param{to-wildcard} to be
  1266. non-wild \term{pathnames}.
  1267. There are no specified keyword arguments for
  1268. \funref{translate-pathname}, but
  1269. implementations are permitted to extend it by adding keyword arguments.
  1270. %The following is deleted because part 2 of EXTRA-RETURN-VALUES didn't
  1271. %pass:
  1272. %
  1273. % There is one specified return value from TRANSLATE-PATHNAME;
  1274. % implementations are permitted to extend it by returning additional
  1275. % values.
  1276. \issue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  1277. \issue{JUN90-TRIVIAL-ISSUES:5}
  1278. \funref{translate-pathname} maps customary case in
  1279. \param{source} into customary case in the output \term{pathname}.
  1280. \endissue{JUN90-TRIVIAL-ISSUES:5}
  1281. \endissue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  1282. \label Examples::
  1283. \code
  1284. ;; The results of the following five forms are all implementation-dependent.
  1285. ;; The second item in particular is shown with multiple results just to
  1286. ;; emphasize one of many particular variations which commonly occurs.
  1287. (pathname-name (translate-pathname "foobar" "foo*" "*baz")) \EV "barbaz"
  1288. (pathname-name (translate-pathname "foobar" "foo*" "*"))
  1289. \EV "foobar"
  1290. \OV "bar"
  1291. (pathname-name (translate-pathname "foobar" "*" "foo*")) \EV "foofoobar"
  1292. (pathname-name (translate-pathname "bar" "*" "foo*")) \EV "foobar"
  1293. (pathname-name (translate-pathname "foobar" "foo*" "baz*")) \EV "bazbar"
  1294. (defun translate-logical-pathname-1 (pathname rules)
  1295. (let ((rule (assoc pathname rules :test #'pathname-match-p)))
  1296. (unless rule (error "No translation rule for ~A" pathname))
  1297. (translate-pathname pathname (first rule) (second rule))))
  1298. (translate-logical-pathname-1 "FOO:CODE;BASIC.LISP"
  1299. '(("FOO:DOCUMENTATION;" "MY-UNIX:/doc/foo/")
  1300. ("FOO:CODE;" "MY-UNIX:/lib/foo/")
  1301. ("FOO:PATCHES;*;" "MY-UNIX:/lib/foo/patch/*/")))
  1302. \EV #P"MY-UNIX:/lib/foo/basic.l"
  1303. ;;;This example assumes one particular set of wildcard conventions
  1304. ;;;Not all file systems will run this example exactly as written
  1305. (defun rename-files (from to)
  1306. (dolist (file (directory from))
  1307. (rename-file file (translate-pathname file from to))))
  1308. (rename-files "/usr/me/*.lisp" "/dev/her/*.l")
  1309. ;Renames /usr/me/init.lisp to /dev/her/init.l
  1310. (rename-files "/usr/me/pcl*/*" "/sys/pcl/*/")
  1311. ;Renames /usr/me/pcl-5-may/low.lisp to /sys/pcl/pcl-5-may/low.lisp
  1312. ;In some file systems the result might be /sys/pcl/5-may/low.lisp
  1313. (rename-files "/usr/me/pcl*/*" "/sys/library/*/")
  1314. ;Renames /usr/me/pcl-5-may/low.lisp to /sys/library/pcl-5-may/low.lisp
  1315. ;In some file systems the result might be /sys/library/5-may/low.lisp
  1316. (rename-files "/usr/me/foo.bar" "/usr/me2/")
  1317. ;Renames /usr/me/foo.bar to /usr/me2/foo.bar
  1318. (rename-files "/usr/joe/*-recipes.text" "/usr/jim/cookbook/joe's-*-rec.text")
  1319. ;Renames /usr/joe/lamb-recipes.text to /usr/jim/cookbook/joe's-lamb-rec.text
  1320. ;Renames /usr/joe/pork-recipes.text to /usr/jim/cookbook/joe's-pork-rec.text
  1321. ;Renames /usr/joe/veg-recipes.text to /usr/jim/cookbook/joe's-veg-rec.text
  1322. \endcode
  1323. \label Affected By:\None.
  1324. \label Exceptional Situations::
  1325. If any of \param{source}, \param{from-wildcard}, or \param{to-wildcard}
  1326. is not a \term{pathname}, a \term{string}, or a \term{stream associated with a file}
  1327. an error \oftype{type-error} is signaled.
  1328. \f{(pathname-match-p \param{source from-wildcard})} must
  1329. be true or an error \oftype{error} is signaled.
  1330. \label See Also::
  1331. \funref{namestring},
  1332. \funref{pathname-host},
  1333. \issue{PATHNAME-LOGICAL:ADD}
  1334. \typeref{pathname},
  1335. \typeref{logical-pathname},
  1336. {\secref\FileSystemConcepts},
  1337. \endissue{PATHNAME-LOGICAL:ADD}
  1338. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1339. {\secref\PathnamesAsFilenames}
  1340. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1341. \label Notes::
  1342. The exact behavior of \funref{translate-pathname} cannot be dictated
  1343. by the \clisp\ language and must be allowed to vary, depending on the
  1344. user interface conventions of the file systems involved.
  1345. The following is an implementation guideline.
  1346. One file system performs this operation by
  1347. examining each piece of the three
  1348. \term{pathnames} in turn, where a piece is a
  1349. \term{pathname} component or a
  1350. \term{list} element of a structured component such as
  1351. a hierarchical directory. Hierarchical directory elements in
  1352. \param{from-wildcard} and
  1353. \param{to-wildcard} are matched by whether they are
  1354. wildcards, not by depth in the directory hierarchy. If the piece in
  1355. \param{to-wildcard} is present and not wild, it is copied into the result.
  1356. If the piece in \param{to-wildcard} is
  1357. \kwd{wild} or \nil, the piece in \param{source} is
  1358. copied into the result. Otherwise, the piece in
  1359. \param{to-wildcard} might be
  1360. a complex wildcard such as \f{"foo*bar"} and the piece in
  1361. \param{from-wildcard}
  1362. should be wild; the portion of the piece in
  1363. \param{source} that matches the
  1364. wildcard portion of the piece in
  1365. \param{from-wildcard} replaces the wildcard
  1366. portion of the piece in
  1367. \param{to-wildcard} and the value produced is used in
  1368. the result.
  1369. \endissue{PATHNAME-WILD:NEW-FUNCTIONS}
  1370. \endcom%{translate-pathname}
  1371. %-------------------- Pathname Merging --------------------
  1372. %%% ========== MERGE-PATHNAMES
  1373. \begincom{merge-pathnames}\ftype{Function}
  1374. \label Syntax::
  1375. \DefunWithValuesNewline merge-pathnames
  1376. {pathname {\opt} default-pathname default-version}
  1377. {merged-pathname}
  1378. \label Arguments and Values::
  1379. \issue{PATHNAME-STREAM}
  1380. \param{pathname}---a \term{pathname designator}.
  1381. \endissue{PATHNAME-STREAM}
  1382. \issue{PATHNAME-STREAM}
  1383. %% 23.1.2 20
  1384. \param{default-pathname}---a \term{pathname designator}.
  1385. \endissue{PATHNAME-STREAM}
  1386. \Default{\thevalueof{*default-pathname-defaults*}}
  1387. \issue{PATHNAME-UNSPECIFIC-COMPONENT:NEW-TOKEN}
  1388. \param{default-version}---a \term{valid pathname version}.
  1389. \endissue{PATHNAME-UNSPECIFIC-COMPONENT:NEW-TOKEN}
  1390. \Default{\kwd{newest}}
  1391. \param{merged-pathname}---a \term{pathname}.
  1392. \label Description::
  1393. %% 23.1.2 19
  1394. Constructs a \term{pathname} from \param{pathname}
  1395. by filling in any unsupplied components with the corresponding values
  1396. from \param{default-pathname} and \param{default-version}.
  1397. %% 23.1.2 22
  1398. Defaulting of pathname components
  1399. is done by filling in components taken from another \term{pathname}.
  1400. \issue{COMPILE-FILE-OUTPUT-FILE-DEFAULTS:INPUT-FILE}
  1401. % Unsupplied components of the output \term{pathname} come from \param{pathname},
  1402. % except that the type should default not to the type of \param{pathname}
  1403. % but to the appropriate default type for output from this program.
  1404. This is especially useful for cases such as
  1405. a program that has an input file and an output file.
  1406. Unspecified components of the output pathname will come from the input pathname,
  1407. except that the type should not default
  1408. %% "not" removed per X3J13. -kmp 05-Oct-93
  1409. %not
  1410. to the type of the input pathname
  1411. but rather to the appropriate default type for output from the program;
  1412. for example, \seefun{compile-file-pathname}.
  1413. \endissue{COMPILE-FILE-OUTPUT-FILE-DEFAULTS:INPUT-FILE}
  1414. %% 23.1.2 23
  1415. If no version is supplied, \param{default-version} is used.
  1416. If \param{default-version} is \nil, the version component will remain unchanged.
  1417. %% 23.1.2 24
  1418. If \param{pathname} explicitly specifies a host and not a device, and
  1419. if the host component of \param{default-pathname} matches the host component
  1420. of \param{pathname}, then the device is taken from the \param{default-pathname};
  1421. otherwise the device will be the default file device for that host. If
  1422. \param{pathname} does not specify a host, device, directory, name,
  1423. or type, each such component is copied from \param{default-pathname}.
  1424. If \param{pathname} does not specify a name, then the version, if not provided, will
  1425. come from \param{default-pathname}, just like the other components. If
  1426. \param{pathname} does specify a name, then the version is not affected
  1427. by \param{default-pathname}. If this process leaves the
  1428. version missing, the \param{default-version} is used.
  1429. If the host's file name syntax provides a way
  1430. to input a version without a name or type, the user can let the name
  1431. and type default but supply a version different from the one in \param{default-pathname}.
  1432. \issue{CLOSED-STREAM-FUNCTIONS:ALLOW-INQUIRY}
  1433. If \param{pathname} is a \term{stream}, \param{pathname} effectively
  1434. becomes \f{(pathname \param{pathname})}. \funref{merge-pathnames}
  1435. can be used on either an open or a closed \term{stream}.
  1436. \endissue{CLOSED-STREAM-FUNCTIONS:ALLOW-INQUIRY}
  1437. %% This follows from "stream associated with a file",
  1438. %% which is implicit in "pathname designator".
  1439. % \issue{PATHNAME-STREAM}
  1440. % It is an error if \param{pathname} is a \term{stream} that is
  1441. % created with \funref{make-two-way-stream},
  1442. % \funref{make-echo-stream},
  1443. % \funref{make-broadcast-stream},
  1444. % \funref{make-concatenated-stream}, \funref{make-string-input-stream},
  1445. % \funref{make-string-output-stream}.
  1446. % \endissue{PATHNAME-STREAM}
  1447. If \param{pathname} is a \term{pathname}
  1448. %% Superfluous. -kmp 29-Aug-93
  1449. %(as returned by \funref{pathname})
  1450. it represents the name used to open the file. This may be, but is
  1451. not required to be, the actual name of the file.
  1452. \issue{PATHNAME-LOGICAL:ADD}
  1453. \funref{merge-pathnames} recognizes a \term{logical pathname} \term{namestring}
  1454. when \param{default-pathname} is a \term{logical pathname},
  1455. \issue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  1456. or when the \term{namestring} begins with
  1457. the name of a defined \term{logical host} followed by a \term{colon}.
  1458. In the first of these two cases,
  1459. \endissue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  1460. the host portion of the \term{logical pathname} \term{namestring}
  1461. and its following \term{colon} are optional.
  1462. \endissue{PATHNAME-LOGICAL:ADD}
  1463. \issue{PATHNAME-LOGICAL:ADD}
  1464. \funref{merge-pathnames} returns a
  1465. \term{logical pathname} if and only if
  1466. its first argument is a \term{logical pathname},
  1467. \issue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  1468. or its first argument is a \term{logical pathname} \term{namestring} with an explicit host,
  1469. or its first argument does not specify a host
  1470. and the \param{default-pathname} is a \term{logical pathname}.
  1471. \endissue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}
  1472. \endissue{PATHNAME-LOGICAL:ADD}
  1473. \issue{PATHNAME-SUBDIRECTORY-LIST:NEW-REPRESENTATION}
  1474. \term{Pathname} merging treats a relative directory specially.
  1475. If \f{(pathname-directory \param{pathname})} is a \term{list} whose
  1476. \term{car} is \kwd{relative}, and
  1477. \f{(pathname-directory \param{default-pathname})} is a \term{list}, then
  1478. the merged directory is the value of
  1479. \code
  1480. (append (pathname-directory \param{default-pathname})
  1481. (cdr ;remove :relative from the front
  1482. (pathname-directory \param{pathname})))
  1483. \endcode
  1484. except that if the resulting \term{list} contains a \term{string} or \kwd{wild}
  1485. immediately followed by \kwd{back}, both of them are removed. This removal of
  1486. redundant \kwd{back} \term{keywords} is repeated as many times as possible.
  1487. If \f{(pathname-directory \param{default-pathname})} is not a \term{list} or
  1488. \f{(pathname-directory \param{pathname})} is not a \term{list}
  1489. whose \term{car} is \kwd{relative}, the merged directory is
  1490. \f{(or (pathname-directory \param{pathname}) (pathname-directory \param{default-pathname}))}
  1491. \endissue{PATHNAME-SUBDIRECTORY-LIST:NEW-REPRESENTATION}
  1492. \issue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  1493. \funref{merge-pathnames} maps customary case in \param{pathname}
  1494. into customary case in the output \term{pathname}.
  1495. \endissue{PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT}
  1496. \label Examples::
  1497. %% 23.1.2 21
  1498. \code
  1499. (merge-pathnames "CMUC::FORMAT"
  1500. "CMUC::PS:<LISPIO>.FASL")
  1501. \EV #P"CMUC::PS:<LISPIO>FORMAT.FASL.0"
  1502. \endcode
  1503. \label Affected By:\None.
  1504. \label Exceptional Situations:\None.
  1505. \label See Also::
  1506. \issue{PATHNAME-LOGICAL:ADD}
  1507. \varref{*default-pathname-defaults*},
  1508. \typeref{pathname},
  1509. \typeref{logical-pathname},
  1510. {\secref\FileSystemConcepts},
  1511. \endissue{PATHNAME-LOGICAL:ADD}
  1512. \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1513. {\secref\PathnamesAsFilenames}
  1514. \endissue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR}
  1515. \label Notes::
  1516. %% 23.1.2 25
  1517. The net effect
  1518. %% removed as redundant to avoid making this paragraph run onto next page by one word.
  1519. % of \funref{merge-pathnames}
  1520. is that if just a name is supplied,
  1521. %% ditto.
  1522. %then
  1523. the host, device, directory, and type will come from \param{default-pathname},
  1524. but the version will come from \param{default-version}.
  1525. If nothing or just a directory is supplied,
  1526. the name, type, and version will come from \param{default-pathname} together.
  1527. \endcom%{merge-pathnames}