aboutsummaryrefslogtreecommitdiff
path: root/direct.c
blob: b6181d5e9e41b44dff6eb173ac31d294e056b071 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 *    file:  direct.c
 *
 *    This file contains the function which reads the names and
 *    sizes of the MPX/OS process files from the disk, and stores
 *    them in the directory entry array.
 */

#include <dos.h>        /* Borland header file */
#include <fcntl.h>      /* Borland header file */
#include <string.h>     /* Borland header file */
#include <dir.h>        /* Borland header file */
#include "mpx.h"

dir direct[MAXSIZE];    /* The array of directory entries. */

/*
 *
 *   directory  -  This procedure performs a sequential read of the MPX
 *	           directory, obtaining all .MPX files up to the size of the
 *                 directory.  These are the file that can be loaded by
 *                 COMHAN. Note that the file specific details are saved in
 *	           the dir structure, direct.
 *
 *   Parameters:   direct   - the array of directory entries.
 *                 dir_size - the capacity of the direct array.
 *
 *   Return value:  The number of files entries made to the
 *                  direct array.
 */


int directory(dir *direct, int dir_size)
{
  int   num_procs;       /* Number of .mpx files found.                 */
  char  filename[15];    /* Name of a file with .mpx extension.         */
  int   done;            /* Flags when no more .mpx files can be found. */
  struct ffblk ffblk;

  num_procs = 0;    /* number of .MPX file entries placed in directory */

  done = findfirst ("*.MPX",&ffblk,0);
  while (!done && num_procs < dir_size) {
      strcpy (filename,ffblk.ff_name);
      strcpy(direct->dirnam,filename);
      direct->dirnam[strcspn(filename,".")] = '\0';
      direct->dirsiz = ffblk.ff_fsize;
      ++num_procs;
      direct++;
      done = findnext(&ffblk);
  }

  return(num_procs);
}