directory.sl 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %
  3. % Directory.SL - File Directory Primitives (TOPS-20 Version)
  4. %
  5. % Author: Alan Snyder
  6. % Hewlett-Packard/CRC
  7. % Date: 13 July 1982
  8. %
  9. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  10. (BothTimes (load common jsys pathnames file-primitives))
  11. (de find-matching-files (filename include-deleted-files)
  12. % Return a list describing all files that match the specified filename. The
  13. % filename may specify a directory and/or may contain wildcard characters.
  14. % Each element of the returned list corresponds to one matching file. The
  15. % format of each list element is:
  16. % (file-name full file name string
  17. % deleted-flag T or NIL
  18. % file-size integer count of pages in file
  19. % write-date integer representing date/time of last write
  20. % read-date integer representing date/time of last read
  21. % )
  22. (setf filename (fixup-directory-name filename))
  23. (let (jfn-word jfn file-name deleted-flag file-size write-date read-date)
  24. (cond
  25. ((and (stringp filename)
  26. (setf jfn-word (attempt-to-get-jfn
  27. filename
  28. (if include-deleted-files
  29. #.(bits 2 8 11 13 17)
  30. #.(bits 2 11 13 17)
  31. )
  32. )))
  33. (for*
  34. (while (>= jfn-word 0))
  35. (do (setf jfn (lowhalfword jfn-word))
  36. (setf file-name (MkString 100 (char space)))
  37. (jsys1 file-name jfn
  38. #.(bits 2 5 8 11 14 35) 0 (const jsJFNS))
  39. (setf file-name (recopystringtonull file-name))
  40. (setf deleted-flag (jfn-deleted? jfn))
  41. (setf file-size (jfn-page-count jfn))
  42. (setf write-date (jfn-write-date jfn))
  43. (setf read-date (jfn-read-date jfn))
  44. )
  45. (collect (list
  46. file-name
  47. deleted-flag
  48. file-size
  49. write-date
  50. read-date
  51. ))
  52. (do (if (FixP (ErrorSet
  53. (list 'jsys1 jfn-word 0 0 0 (const jsGNJFN))
  54. NIL NIL)) (setf jfn-word -1)))
  55. ))
  56. )))
  57. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  58. % Auxiliary Functions:
  59. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  60. (de fixup-directory-name (pn)
  61. % Replace all missing Name, Type, and Version components of the specified
  62. % filename with "*".
  63. (let ((wild-name (make-pathname 'name 'wild)))
  64. (setf pn (pathname pn))
  65. (namestring (merge-pathname-defaults pn wild-name 'wild 'wild))))