Directory Manipulation Routines Generalized Routines -- DIRF and DIRFS Buffer Allocation Routine -- DBUFFER Disk Parameter Information Extraction Routine -- DPARAMS Free Space Computation Routine -- DFREE File Size Computation Routine -- FSIZE Directory Load Routines -- DIRLOAD and DIRSLOAD Directory Alphabetization Routine -- DIRALPHA Directory Entry Selection Routine -- DIRSEL Directory Pack Routine -- DIRPACK :Directory Manipulation Routines Thió seô oæ SYSLI routineó concernó itselæ witè thå loadinç oæ anä accesó oæ á disë directorù foò thå generaì purposeó oæ thå user. Included in this set of routines are the functions of: 1. Preallocation of buffer space for the routines 2. Two routines which load all undeleted directory entries into a buffer, constantly checking for memory overflow as they go DIRLOAD loads the first entry for each file (this is the faster of the two) DIRSLOAD loads the last entry for each file (this routine is required if the user wishes to compute file sizes) 3. A routine to determine the amount of free space on the disk 4. A routine to compute the size of a file in K 5. A routine to sort a loaded directory by file name and type or by file type and name 6. A routine to select (by marking) a set of directory entries which match a given ambiguous file spec 7. A routine to pack the loaded directory, leaving in it only those entries marked by the select routine :Generalized Routines -- DIRF and DIRFS Routine Name: DIRF and DIRFS Functionº Thió routinå initializeó thå buffeò area¬  loadó á disë directory¬  selectó  á  seô  oæ fileó froí thå  loadeä  directorù specifieä  bù  thå user'ó ambiguouó filå namå anä á  passeä  flaç (whicè indicateó iæ Systeí fileó arå selected¬  Non-systeí  fileó arå  selected¬  alì  useò  areaó  arå tï  bå  covered¬  anä  whaô particulaò  useò areá ió tï bå covereä iæ alì useò areaó arå  noô selected)¬ packó thå directory¬ anä alphabetizeó thå directorù bù filå namå anä filå type. Iæ  DIRÆ ió used¬  thå processinç proceedó fasteò sincå onlù thå  firsô entrù oæ eacè filå ió loadeä intï thå  memorù  buffer® Filå sizinç informatioî ió noô includeä iî thió load¬ however. Iæ DIRFÓ ió used¬ thå processinç ió somewhaô slower¬ buô thå lasô  entrù foò eacè filå ió loadeä ratheò thaî thå first®  Filå sizinç  informatioî  ió  containeä  iî  thió  entry¬   anä   thió informatioî caî bå useä bù thå FSIZÅ routine. Inputs: HL points to a dynamic buffer which extends from after the user's code and buffer areas to the end of the TPA DE points to the first byte of the FCB used to specify the ambiguous file name; only the chars in the FN and FT fields are significant, so this need not be a true FCB and may be as short as 12 bytes A is the selection flag, structured as follows: Bit 7 - If Set, Select Non-System Files Bit 6 - If Set, Select System Files Bit 5 - If Set, Select All User Areas Bits 4-0 - If Bit 5 is Cleared, contains number of User Area to Select Outputs: HL points to the first file entry in the buffer; each file entry is 16 bytes long BC contains the number of files selected       A contains an error flag; A=0 and Zero Flag Set       (Z) indicates TPA overflow error during load of       directory entries; A<>0 and NZ indicates load OK Registers Affected: HL, BC, PSW SYSLIB Routines Called: DBUFFER, DIRLOAD, DIRSEL, DIRPACK, DIRALPHA Special Error Conditions: As outline for the A register       above. :Buffer Allocation Routine -- DBUFFER Routine Name: DBUFFER Function: Thió  routinå allocateó thå buffeò spacå necessarù  foò thå  seô oæ directorù functionó iî general®  Iî  particular¬  iô allocateó thå necessarù spacå foò thå alphabetizatioî functioî aó welì aó thå loadeä directorù itself®  Thió routinå musô bå  useä iæ  thå  DIRALPHÁ  routinå  ió  tï bå  lateò  useä  tï  sorô  thå directory»  thió  routinå  allocateó alì thå spacå  necessarù  bù DIRALPHÁ tï sorô thå routinå (pointeò space)® Iæ thió routinå ió called¬ iô ió noô necessarù tï calì thå DPARAMÓ routine. Inputs: HL points to the beginning address of a dynamic       buffer area which extends to under the CCP Outputs: HL points to the first byte at which the directory       entries are to be loaded       A=0 and Zero Flag is Set (Z) if the CCP is       already overrun; else, A<>0 and NZ Registers Affected: HL, PSW SYSLIB Routines Called: DPARAMS Special Error Conditions: As indicated by A reg and Z flag :Disk Parameter Information Extraction Routine -- DPARAMS Routine Name: DPARAMS Function: Thió  routinå  extractó necessarù informatioî froí thå  Disë Parameteò  Blocë (DPB© anä storeó iô awaù iî somå globaì  bufferó useä bù otheò Disë Directorù Routines® Thå informatioî extracteä ió noô oæ generaì concerî bù thå programmer®  ALÌ THÅ PROGRAMMEÒ NEEDÓ  TÏ KNO× IÓ THAÔ THIÓ ROUTINÅ MUSÔ BÅ CALLEÄ AÔ LEASÔ  ONCÅ BEFORÅ THÅ DIRLOAÄ OÒ DIRSLOAÄ ROUTINÅ IÓ CALLED® Iæ thå DBUFFEÒ routinå  ió  called¬  theî iô ió noô necessarù  tï  calì  DPARAMÓ again. Foò thå informatioî oæ thå reader¬ thå followinç informatioî ió extracted:       BLKSHF <-- Block Shift Factor (1 Byte)       BLKMSK <-- Block Mask (1 Byte)       EXTENT <-- Extent Mask (1 Byte)       BLKMAX <-- Max Number of Blocks on Disk (2 Bytes)       DIRMAØ <-- Maø Numbeò oæ Diò Entrieó (² Bytes) Thió  routinå automaticallù adjustó foò versionó 1.´ anä 2.² oæ CP/Í anä ió compatablå witè botè versionó oæ CP/M. Inputs: None Outputs: None (Information Extracted into Buffers) Registers Affected: None SYSLIB Routines Called: None Special Error Conditions: None :Free Space Computation Routine -- DFREE Routine Name: DFREE Function: Thió  routinå  computeó thå amounô oæ freå spacå (iî  Ë bytes© lefô oî disk. Thå  routinå  DPARAMÓ  (oò  DBUFFER¬  sincå  iô  alsï  calló DPARAMS©  musô bå calleä beforå thió routinå ió useä sï thaô  thå correct disk parameter information is loaded for it. Inputs: None Outputs: DE = Amount of Free Disk Space in K Bytes Registers Affected: DE SYSLIB Routines Called: None Special Error Conditions: None :File Size Computation Routine -- FSIZE Routine Name: FSIZE Function: Thió  routinå  computeó thå sizå oæ á filå whoså  entrù (whicè  MUSÔ bå loadeä bù DIRSLOAD© ió pointeä tï  bù  HL®  Thió routinå wilì work¬ buô generallù returî incorrecô results¬ iæ thå entrù pointeä tï waó loadeä bù DIRLOAÄ instead. Thå  routinå  DPARAMÓ  (oò  DBUFFER¬  sincå  iô  alsï  calló DPARAMS©  musô bå calleä beforå thió routinå ió useä sï thaô  thå correct disk parameter information is loaded for it. Inputs: HL points to first byte of file entry Outputs: DE contains the file size in K Bytes Registers Affected: DE SYSLIB Routines Called: None Special Error Conditions: None :Directory Load Routines -- DIRLOAD and DIRSLOAD Routine Name: DIRLOAD and DIRSLOAD Function: DIRLOAÄ  anä  DIRSLOAÄ loaä entrieó foò  alì  undeleteä fileó  oî  thå  currentlù loggeä iî disë intï thå  memorù  buffeò pointeä tï bù HL® Alì entrieó arå 1¶ byteó long. DIRLOAÄ  ió fasteò thaî DIRSLOAD®  Iô loadó jusô thå  firsô entrù oæ eacè filå oî disk®  DIRLOAD¬  however¬  shoulä bå  useä onlù   iæ  filå  sizinç  informatioî  ió  noô  requireä  bù   thå applicationó program. DIRSLOAÄ  loadó  jusô thå LASÔ entrù oæ eacè filå  oî  disk® Thió  entrù containó thå necessarù filå sizinç informatioî  whicè maù bå useä bù FSIZÅ tï computå thå sizå oæ thå loadeä file. Iæ  thå  TPÁ ió filleä durinç DIRLOAÄ oò DIRSLOAÄ anä  therå arå stilì morå filå entrieó tï load¬  thå loaä wilì bå halteä anä aî erroò returî wilì bå madå tï thå caller®  Oî return¬  iæ  A=° anä  thå  Zerï  Flaç  ió Seô (Z)¬  theî á  loaä  erroò  occurred» otherwise¬ thå loaä waó OK. Inputs: HL points to the first byte of the directory buffer       area; this area extends from after the last buffer       used by the applications program to the page       before the CCP. If alphabetization is to be done,       the value returned in HL by DBUFFER is a correct       input for DIRLOAD or DIRSLOAD       A=0 and Zero Flag is Set (Z) if TPA Overflow;       A<>0 and NZ if load OK Outputs: BC is the number of files loaded into the buffer Registers Affected: BC SYSLIB Routines Called: None Special Error Conditions: If TPA is filled and load is       incomplete, A=0 and Zero Flag is Set (Z) as error indic :Directory Alphabetization Routine -- DIRALPHA Routine Name: DIRALPHA Function: Tï alphabetizå thå fileó iî thå directorù pointeä tï bù HÌ  bù eitheò filå namå anä typå (STEST.ASÍ goeó beforå TEST.AAA© oò bù filå typå anä namå (TEST.AAÁ goeó beforå STEST.ASM). Inputs: HL points to first directory entry       BC contains the number of files to sort       Á ió thå sorô flag» A=° meanó sorô bù filå namå anä            then file type, A<>0 means by file type and name Outputs: None (directory list is sorted) Registers Affected: PSW SYSLIB Routines Called: PRINT Special Error Conditions:       Iô  ió possible¬  althï highlù unlikelù froí alì  testó      giveî  sï  far¬  thaô  DIRALPHÁ maù experiencå  aî  internaì      error. If this happens, the message:       DIRALPHA -- Pointer Error      wilì bå printeä anä thå routinå wilì aborô tï CP/M® Iæ thió      happens¬  pleaså  reporô  thió probleí anä  bå  prepareä  tï      duplicatå thå exacô situatioî whicè causeä thió erroò tï thå      author, Richard Conn. :Directory Entry Selection Routine -- DIRSEL Routine Name: DIRSEL Function: DIRSEÌ  selectó  alì  entrieó iî thå  directorù  buffeò whicè  matcè thå ambiguouó filå namå specifieä iî thå FΠ anä  FÔ fieldó  oæ  thå  FC pointeä tï bù DÅ upoî entrù  tï  DIRSEL®  Á selectioî  flaç ió alsï passeä tï DIRSEÌ iî thå Á  register¬  anä thió flaç telló DIRSEÌ whetheò oò noô tï includå Non-Systeí fileó anä Systeí fileó iî thå selectioî anä whetheò tï selecô fileó  iî alì useò areaó oò iî á particulaò useò area. DIRSEÌ  identifieó thå selecteä filå entrieó bù settinç  thå Mosô  Significanô Biô oæ thå firsô bytå oæ eacè oæ theså  entrieó tï ± iæ thå entrù ió selected®  DIRSEÌ makeó nï otheò changeó tï thå filå entrieó iî thå directorù buffer. Inputs: HL points to the directory buffer       DÅ  pointó tï thå FC containinç thå  ambiguouó  FÎ       and FT fields; only the first 12 bytes are needed       BC contains the number of files in the directory       A contains a selection flag, organized as follows:       Bit 7 - Select Non-System Files       Bit 6 - Select System Files       Bit 5 - Select Files in All User Areas       Bits 4-0 - If Bit 5 is 0, indicates number of       User Area to select files from Outputs: None (MSBs of selected entries are set) Registers Affected: None SYSLIB Routines Called: None Special Error Conditions: None :Directory Pack Routine -- DIRPACK and DIRNPACK Routine Name: DIRPACK Function: DIRPACË  restructureó thå directorù buffeò  tï  contaiî onlù thoså entrieó markeä bù DIRSEL®  Iî thió way¬ thoså entrieó NOÔ  markeä  bù DIRSEÌ arå discardeä froí thå  buffeò  (actually¬ jusô  takeî ouô oæ consideration¬  buô thå contentó oæ thå buffeò afteò  thå  lasô  selecteä entrù ió  noô  guaranteeä  tï  contaiî anythinç significant). Thå  Mosô  Significanô Biô oæ thå firsô bytå oæ alì  entrieó remaininç iî thå directorù buffeò ió reseô tï ° aó á sidå  effecô oæ DIRPACK. Inputs: HL points to the directory buffer       BC contains the number of files in the buffer Outputs: BC contains the number of files (those selected by       DIRSEL) remaining in the directory buffer Registers Affected: BC SYSLIB Routines Called: None Special Error Conditions: None Routine Name: DIRNPACK Function: DIRNPACË  restructureó thå directorù buffeò tï  contaiî onlù  thoså  entrieó NOÔ markeä bù DIRSEL®  Iî thió  way¬  thoså entrieó markeä bù DIRSEÌ arå discardeä froí thå buffeò (actually¬ jusô takeî ouô oæ consideration¬  buô thå contentó oæ thå  buffeò afteò  thå  lasô  selecteä  entrù ió noô  guaranteeä  tï  contaiî anythinç significant). Thå  Mosô Significanô Biô oæ thå firsô bytå oæ  alì  entrieó remaininç  iî thå directorù buffeò ió reseô tï ° aó á sidå effecô oæ DIRNPACK. Thå  routinå  DIRSEÌ MUSÔ bå calleä beforå DIRNPACË ió  useä sincå  DIRNPACË useó aî internaì flaç seô bù DIRSEÌ  (foò  SYSTEÍ and R/O information). Inputs: HL points to the directory buffer       BC contains the number of files in the buffer Outputs: BC contains the number of files (those NOT selected       by DIRSEL) remaining in the directory buffer Registers Affected: BC SYSLIB Routines Called: DIRPACK Special Error Conditions: None