aboutsummaryrefslogtreecommitdiff
path: root/ksiders/atrdir.c
blob: 62920c004e1b1fe5650eacb544e9844310afb7dd (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* Copyright 1997 Ken Siders */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "atr.h"
#include "atdos.h"

void help(void)
   {
   printf("usage: atrdir atrname.atr [filespec]\n");
   printf("\n");
   printf("\n\n");
   }


int main( int argc, char **argv)
   {
   AtrFilePtr atr;
   int minCnt;
   char option;
   static char mask[80];


   printf("AtrDir Version 0.9u (c)1997 Ken Siders\n");
	printf("Ported and modified by B. Watson, 2007\n");
   printf("This program may be freely distributed\n\n");

   if (argc < 2)
      {
      help();
      exit(2);
      }
   
   if (argv[1][0] == '-')
      {
      option = argv[1][1];
      minCnt = 3;
      }
   else
      {
      option = 0;
      minCnt = 2;
      }

   if ( argc != minCnt && argc != minCnt + 1)
      {
      help();
      exit(4);
      }

   if (option && option != 'W' && option != 'w' )
      {
      help();
      exit(5);
      }

   atr = OpenAtr(argv[minCnt-1]);
   if (atr == 0)
      {
      printf("Error reading ATR file: %s\n", argv[1]);
      exit(2);
      }
   else
      {
      CloseAtr(atr);
      }

   if (argc == minCnt)
      strcpy(mask, "*.*");
   else
      strcpy(mask, argv[minCnt]);
   printf("Directory of %s:%s:\n", argv[minCnt-1], mask);
   AtariDirectory( argv[minCnt-1], mask);
      
   





	/* printf("\n%d file(s)\n", count); */

	exit(0);
   }