-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·58 lines (48 loc) · 1.24 KB
/
main.cpp
File metadata and controls
executable file
·58 lines (48 loc) · 1.24 KB
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
#include <iostream>
#include <cstring>
#include <fstream>
#include "list.h"
#include "directory.h"
#include "list.cpp"
using namespace std;
void reader(List<File*>* list, const char* filename)
{
char line[256], *nline;
ifstream inf(filename);
while(inf.getline(line, 256))
{
char test = line[0];
switch (test)
{
{case 'd':
nline = strrchr(line, ' ');
nline += 1;
File* insert = new Directory(nline);
list->insert(insert);
break; } //directory case
{default:
nline = strrchr(line, ' ');
nline += 1;
File *insert = new File(nline);
list->insert(insert);
break; } //default case (general files)
} //switch control
} //while reading the file
} //reader ()
int main(int argc, const char **argv)
{
char filename[100];
List<File*> lf;
reader(&lf, argv[1]);
while (strncmp(filename, "Done", 4))
{
cout << "Please enter a file name (Done = exit): ";
cin >> filename;
if (strncmp(filename, "Done", 4))
{
File* k = new File(filename);
lf.find(k);
} //if user did not type "Done"
} //while user did not type "Done" yet
return 0;
} // main()