summaryrefslogtreecommitdiffstats
path: root/MountArray.cpp
blob: 92784893ce7fab245077da6055c64263b7e81d85 (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
#include "MountArray.h"
#include <stdio.h>
#include <string.h>

MountArray::MountArray (BOOL recurse)
{
	MountCount = 0;
	if (recurse == FALSE) {
		char *Word;

		MountArr = new string *[50];
		FILE *conffile = fopen ("/etc/mtab", "r");

		if (conffile) {
			char confline[350];

			while (fgets (confline, 350, conffile) != 0) {
				int wordcount = 0;

				Word = strtok (confline, " ");
				while (Word != NULL) {
					Word = strtok (NULL, " ");
					if (wordcount == 0) {
						//printf("%s\n",Word);
						MountArr[MountCount] = new string (Word);
						MountCount++;
					}
					wordcount++;
				}
				//printf("%s\n",confline);
			}
		}
	}
}

MountArray::~MountArray ()
{
	int i;

	for (i = 0; i < MountCount; i++)
		delete MountArr[i];
	delete MountArr;
}

BOOL MountArray::MountCheck (string & instring)
{
	int counter;

	BOOL retval = FALSE;

	for (counter = 0; counter < MountCount; counter++)
		if (*MountArr[counter] == instring)
			retval = TRUE;
	return retval;
}