home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / ZCPR33 / A-R / CLEAND18.LBR / CLEANDIR.HZS / CLEANDIR.HIS
Text File  |  2000-06-30  |  11KB  |  239 lines

  1. ;    Program:  CLEANDIR
  2.  
  3. ;    Function: Sorts the directory of a disk into increasing or decreasing
  4. ;          order.  Checks for the following conditions:
  5.  
  6. ;            Duplicate directory entries
  7. ;            User # > 31
  8. ;            Extent # > 31
  9. ;            Illegal characters in the filename
  10. ;            Record count > 80h
  11. ;            Same allocation group assigned to multiple files, or
  12. ;            to the same file twice
  13.  
  14. ;          Deletes 0-length files other than those with names starting
  15. ;          with a '-'or a space, as used by some disk catalog programs.
  16.  
  17. ;          Reports the names of all 0-length files
  18.  
  19. ;          Removes all erased entries from the directory, writing
  20. ;          continuous 'e5' (hex) bytes from after the last active
  21. ;          directory entry to the end of the directory.
  22.  
  23. ;          May be invoked in a 'Check' mode, such that it does all of
  24. ;          the above checks, but does not write the modified directory
  25. ;          back to the disk.
  26.  
  27. ;    Modification History:
  28.  
  29. ; Version 1.8   Steve Dirickson  14 June 87
  30.  
  31. ; None of the main-line routines except RDDIR and WRDIR could properly handle
  32. ; an empty disk.  This caused the program to crash the system when it tried
  33. ; to clean a disk with no directory entries (specifically, the SWAP routine
  34. ; junked up the entire first 64K of memory, clobbering the operating system,
  35. ; but none of the other routines would have handled this situation properly
  36. ; either).  Rather than have each routine perform a separate check for an
  37. ; empty disk, the RDDIR routine checks, and skips directly to the write
  38. ; routine if there are no active entries in the packed directory.
  39.  
  40. ; Version 1.7   Steve Dirickson   7 June 87
  41.  
  42. ; Fixed an error in the directory write routine that caused the program to 
  43. ; write too many sectors if there were less than 4 active directory entries
  44. ; on the disk being cleaned.  Tightened up the code a little and redid the
  45. ; storage space allocation.
  46.  
  47. ; Version 1.6   Steve Dirickson   25 May 87
  48.  
  49. ; Several changes, some major, some minor.
  50. ;     Major Modifications:
  51. ;          1) Changed the directory-read routine completely, using an
  52. ;          incremental-read procedure I developed while working on my
  53. ;          RESTORE utility.  The directory is read in, one 128-byte
  54. ;          sector at a time, and erased entries are skipped over as the
  55. ;          directory is read in.  This makes the program able to read in
  56. ;          the directory of any disk that has no more active directory
  57. ;          entries than will fit in the available space.  Thus, the
  58. ;          maximum # of directory entries the disk can hold (DRM) no
  59. ;          longer has any effect on the operation of the program.  This
  60. ;          eliminates the problem for which Pete Lyman's '841201'
  61. ;          modification provided a partial solution.  All checks for
  62. ;          erased entries in the other sections of the code (packing,
  63. ;          filename checking) were deleted, since erased entries never
  64. ;          make it into the directory.
  65. ;       2) Corrected a serious error in the disk read/write routines.
  66. ;          The sector selection was not taking any sector translation
  67. ;          into consideration.  The sectors on each track were being
  68. ;          selected using the BIOS SETSEC routine, but the entering
  69. ;          sector numbers always started at 1, and were not translated.
  70. ;          This would work fine for most systems, since few disk formats
  71. ;          have a physical sector 0 (and since the same error was made on
  72. ;          the disk write that was made on the read.  In this case, two
  73. ;          wrongs do make a right!).  But, for those that do, it caused
  74. ;          the first physical sector on the disk to be skipped, resulting
  75. ;          in the first 4 entries in the directory being missed, and caused
  76. ;          problems at the end of the track, when the BIOS was told to
  77. ;          read or write a non-existent sector.  The new version always
  78. ;          starts the track at logical sector #0, calls the SECTRN routine
  79. ;          to convert this to a physical sector #, and selects that sector
  80. ;          for the data transfer.
  81. ;       3) Fixed a bug in the allocation checking routine that caused it
  82. ;          to only check the first block allocated to all directory entries
  83. ;          after the first one against the rest of the directory.  This
  84. ;          resulted in probably 30-40% of all duplicate allocation problems
  85. ;          being missed by the program.
  86. ;     Minor changes:
  87. ;          1) Removed the 'NOBOOT' variable and all references to it.  This
  88. ;          seems to be left over from some earlier version that did not
  89. ;          rewrite the directory if it was already sorted.  The way it
  90. ;          was used in Version 1.5, it always rewrote the directory
  91. ;          anyway, since the variable was never set to skip the write.
  92. ;       2) The program error flag was not being set for the condition where
  93. ;          the same allocation group was assigned to two different files,
  94. ;          IF the disk had more than 255 allocation groups (DSM > 255).
  95. ;       3) Added code to automatically log in the modified directory if
  96. ;          no errors are found by calling ZRDOS function 37, if the system
  97. ;          is ZRDOS 1.5 or later.  This code is assembled conditionally
  98. ;          based on the flag 'ZRD15'.  If you are using an earlier version
  99. ;          of ZRDOS and don't need this log in (or are using CP/M's BDOS,
  100. ;          where function 37 doesn't always work correctly), change the
  101. ;          definition of ZRD15 to 'FALSE'.  If you are using the CP/M BDOS,
  102. ;          you MUST make this change, or suffer the consequences!
  103. ;       4) Incorporated a routine developed by Joe Wright to swap the s2
  104. ;          and extent bytes before and after the sort.  This allows the
  105. ;          directory to be sorted in 'really' increasing order for disks
  106. ;          with files larger than 512K.
  107. ;       5) Restructured the program as real inline routines rather than
  108. ;          a 'main loop' that consisted only of a bunch of calls to sub-
  109. ;          routines that only got executed once each.
  110.  
  111. ; Version 1.5   Steve Dirickson   15 Feb 87
  112.  
  113. ; Fixed a bug I discovered in working with my RESTORE disk restoration
  114. ; utility.  RESTORE was giving people problems by telling them that their
  115. ; directory was not sorted.  I discovered that, for files larger that 512K,
  116. ; CP/M starts reusing extent numbers, and uses the s2 field of the directory
  117. ; entry as an auxiliary record counter.  I fixed RESTORE, but found that
  118. ; CLEANDIR gave me 'Duplicate Directory Entry' error messages on the disk.
  119. ; The fix was the same as for RESTORE:  make the comparison routine check
  120. ; the first 15 characters in the entry, rather than the first 13.  The
  121. ; routine at PACK1A: was modified, and it works fine now.  Also, the check for
  122. ; an extent > 31 was using a 'cp  1fh' and jumping to the error routine if 
  123. ; no carry resulted.  This caused the program to ALWAYS report this error for
  124. ; any file which had an extent number 31, i.e., any file > 496K (guess most
  125. ; people, like me, just don't have that many files that big).
  126. ; Since the modification history at the beginning of the file was getting so
  127. ; long, I moved it into a separate .HIS file, and added a short description
  128. ; to the start of the source file instead.
  129.  
  130. ; Version 1.4 by David McCord 11/20/86.  Minor changes so that source
  131. ; would assemble properly with ZAS.  No code changes.
  132.  
  133. ;    TITLE    CLEANDIR  --  Version 1.3B, with directory checking
  134.  
  135. ; Program:  CLEANDIR
  136. ; Derivation:  SAP 3.8 (see following history for authors)
  137. ; Derivation By:  Richard Conn
  138. ; Version: 1.1
  139. ; Date:  28 November 1984
  140. ; Previous Versions: 1.0 (20 June 84)
  141.  
  142. ; Checking features added -- Michael Bate
  143.  
  144. ; Version 1.3B - 4/3/86
  145.  
  146. ; Bug fixes -
  147.  
  148. ;  (1) Incorporated from SAP39 (Last directory entry not participating
  149. ;                in sort)
  150. ;  (2) Incorporated from SAP44 (Flag bits sometimes moved from one file
  151. ;                to another - because swapping during
  152. ;                sort began after mismatch found)
  153. ;    THANKS for above to Bill Duerr
  154.  
  155. ;  (3) '@' flagged as a "bad" character if used in file name.
  156.  
  157. ;  (4) Bug in PACK procedure -- missing duplicate directory entries
  158.  
  159. ; Version 1.2B - 2/25/86
  160.  
  161. ; Bug fix -- Wrong file name reported when same allocation block used
  162. ;        in a single file.
  163.  
  164. ; Checks directory for:
  165. ;    Duplicate entries (same filename, user#),
  166. ;    Same allocation block # used more than once,
  167. ;    Extent # > 31 (1Fh)
  168. ;    Record Count > 80h
  169. ;    Illegal characters in filename
  170. ;    User # > 31
  171.  
  172. ; Sets ZCPR3 error flag if any of the above, else resets flag to zero.
  173. ; Also reports zero-length files whose name does not start with
  174. ; '-' or space.  (Erases these files).  Reports total number of ALL
  175. ; zero-length files (of whatever name).
  176.  
  177. ; Possible to invoke for check-only.
  178.  
  179. ; This version uses Z80 code.
  180.  
  181. ; bug fix ;841201    Peter T Lyman
  182. ; Version 1.1P
  183.  
  184. ;    Search for ';841201' to locate the code
  185.  
  186. ;    CLEANDIR can and does wipe out the operating system
  187. ;    (also known as a crash) whenever the maximum size of
  188. ;    the directory (DRM) exceeds the available memory....
  189.  
  190. ;    Maybe that is a good feature, since you at least don't
  191. ;    hurt the disk...
  192.  
  193. ;    However on my hard disk I have two platters with
  194. ;    DRM equal to 2048....  In this case CLEANDIR crashes...
  195.  
  196. ;    The fix that I have added (I did this with an early version
  197. ;    of SAP) gives you a choice....  If DRM is greater than
  198. ;    the space available betwwen BUF and BDOS,  you are given
  199. ;    a choice with proceeding if the actual number of directory
  200. ;    entries is less than or equal to the space available....
  201. ;    If not you ABORT.....
  202.  
  203. ;    The down side risk of this modification is that if you
  204. ;    proceed ("Y") when the actual number of files exceeds
  205. ;    the space available,  you lose all the directories entries
  206. ;    which don't fit in the available space....
  207.  
  208. ;    With out the fix the system crashes and you cannot clean the
  209. ;    directory...  With the fix you can clean the directory, but
  210. ;    you can lose files if you don't pay attention....
  211.  
  212. ; v3.8 SORT AND PACK CP/M DISK DIRECTORY - 10/16/83
  213.  
  214. ; THIS PROGRAM READS THE DISK DIRECTORY TRACKS, SORTS THEM ALPHABETICALLY
  215. ; THEN REPLACES THEM ON THE DISK.  ALL UNUSED OR ERASED AREAS ON THE DIR-
  216. ; ECTORY TRACK ARE REFORMATTED WITH CONTINUOUS 'E5' CHARACTERS.  (THIS
  217. ; ERASES PREVIOUS FILE NAMES WHICH HAVE BEEN DEACTIVATED.)  SORTING THE
  218. ; DIRECTORY IN THIS MANNER OFFERS MANY ADVANTAGES.  SOME OF THEM ARE:
  219.  
  220. ;    1)  ALLOWS 'DIR' TO SHOW AN ALPHABETIZED LISTING
  221. ;    2)  ELIMINATES POTENTIAL PROBLEMS WITH "UNERASE" PROGRAMS
  222. ;    3)  SPEEDS UP ACCESS VIA 'SD' AND OTHER SPECIAL PROGRAMS
  223. ;    4)  ASSISTS ON WORKING DIRECTLY ON THE DISK WITH 'DUU', ETC.
  224. ;    5)  REMOVES FILES FROM THE DISK SOMEBODY ELSE COULD RECOVER
  225.  
  226. ;                - Notes by Irv Hoff W6FFC
  227.  
  228. ; 1977    Written by L. E. Hughes.  Modified extensively since by Bruce
  229. ;    Ratoff, Keith Petersen, James Prest, Ron Fowler, Frank Gaude',
  230. ;    Irv Hoff and likely others.
  231.  
  232. ; 10/16/83 Now using a Shell-Metzner sort which speeds the sorting time
  233. ;       considerably, especially on large directories. (SFK)
  234.  
  235. ; 07/27/83 Shows an error flag for MP/M and CP/M+ both.  Rewrites dir-
  236. ;       tory even if previously sorted, to insure erased programs at
  237. ;   v3.7   end of directory are properly cleared.
  238. ;                    - Irv Hoff
  239.