1: /*	dirhdl.c	1.7	83/05/13	*/
   2: 
   3: #include <stdio.h>
   4: #include "cpmio.h"
   5: 
   6: /* Display cp/m directory on stdout */
   7: 
   8: dispdir()
   9: {
  10: 
  11:     int cnt;
  12:     int filecnt = 0;
  13:     int blkcnt ;
  14: 
  15:     for (cnt=0; cnt<maxdir; cnt++) {
  16:         if ((dirbuf+cnt)->status != (char) 0xe5) {
  17:            if ((dirbuf+cnt)->extno == '\0' ) {
  18:             printf("%.8s %.3s",(dirbuf+cnt)->name,
  19:                 (dirbuf+cnt)->ext);
  20:             if (++filecnt%4 == 0)
  21:                 printf("\n");
  22:             else
  23:                 printf("   :   ");
  24:            }
  25:         }
  26:     }
  27:     blkcnt = blks_used();
  28:     if (filecnt%4 > 0) printf("\n");
  29:     if (filecnt == 0)
  30:         printf("No files\n");
  31:     else
  32:         printf(
  33:         "Total of %d files. %d blocks used, %d blocks free.\n"
  34:         ,filecnt, blkcnt,seclth*sectrk*(tracks-2)/blksiz - blkcnt);
  35:     return;
  36: }
  37: 
  38: getdir()
  39: 
  40: {
  41: 
  42:     int bl, blks;
  43:     int offset = 0;
  44: 
  45:     blks = maxdir*32/blksiz;
  46:     if ((maxdir*32)%blksiz > 0)
  47:         ++blks;
  48:     for (bl = 0; blks > 0; bl++, blks--) {
  49:         if (getblock(bl,dirbuf+offset,-1) == EOF) {
  50:             fprintf(stderr, "getdir: fatal error\n");
  51:             exit (0);
  52:         }
  53:         offset += blksiz/32;
  54:     }
  55: }
  56: 
  57: 
  58: savedir()
  59: 
  60: {
  61: 
  62:     int bl, blks;
  63:     int offset = 0;
  64: 
  65:     blks = maxdir*32/blksiz;
  66:     if ((maxdir*32)%blksiz > 0)
  67:         ++blks;
  68:     for (bl = 0; blks > 0; bl++, blks--) {
  69:         if (putblock(bl,dirbuf+offset,-1) == EOF) {
  70:             fprintf(stderr, "savedir: fatal error\n");
  71:             exit (0);
  72:         }
  73:         offset += blksiz/32;
  74:     }
  75: }
  76: 
  77: /* Search the cp/m directory for the file given by the input
  78:  * parameters, return -1 if not found,
  79:  * directory index to the file's first extent is
  80:  * returned if found.
  81:  */
  82: 
  83: searchdir(name,ext)
  84: char *name, *ext;
  85: 
  86: {
  87:     int ind;
  88: 
  89:     for (ind = 0; ind < maxdir; ++ind)
  90:     {
  91:         if ((dirbuf+ind)->status == (char) 0xe5) continue;
  92:         if ((strncmp(name,(dirbuf+ind)->name,8) == 0) &&
  93:             (strncmp(ext, (dirbuf+ind)->ext, 3) == 0) &&
  94:             ((dirbuf+ind)->extno == '\0')) return(ind);
  95:     }
  96:     return(-1);
  97: }

Defined functions

dispdir defined in line 8; used 2 times
getdir defined in line 38; used 1 times
Last modified: 1983-06-24
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1024
Valid CSS Valid XHTML 1.0 Strict