-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfindingmissingfiles.cpp
More file actions
131 lines (124 loc) · 3.18 KB
/
Copy pathfindingmissingfiles.cpp
File metadata and controls
131 lines (124 loc) · 3.18 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <fstream>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iterator>
using namespace std;
int l=0;
#define a textfile[l]
#define b textfile[l+1]
#define c textfile[l+2]
#define d textfile[l+3]
#define e textfile[l+4]
int length;
int k;
vector<string> updatevector(fstream &tempfile,int &nooflines)
{
vector<string> temp;
if (tempfile.good())
{
l=0;
length=0;
tempfile.seekg (0, tempfile.end);
length = tempfile.tellg();
tempfile.seekg (0, tempfile.beg);
char * buffer = new char [length];
//cout << "Reading " << length << " characters... ";
// read data as a block:
tempfile.read (buffer,length);
string textfile(buffer);
//cout<<textfile<<endl;
string line;
nooflines=0;
for(;l<length;l++)
{
if(a=='\n' && l<length-1)
{
if(l!=0)
{
if(b=='T')
{
temp.push_back(line);nooflines++;
line="";
}
else if(b=='\n')
{
continue;
}
}
else
{
continue;
}
}
else if(l==length-1)
{
temp.push_back(line);nooflines++;
line="";
}
else
{
line+=textfile[l];
}
}
sort(temp.begin(),temp.end());
tempfile.close();
delete[] buffer;
textfile="";
}
else
{
cout<<"End of file"<<k<<" reached for some reason"<<endl;
}
k++;
return temp;
}
void missingfile(fstream &temp,vector<string> &vtemp, vector<string> &ftemp)
{
vector<string> v;
vector<string>::iterator it;
//cout<<"it has entered the function"<<endl;
set_difference(vtemp.begin(),vtemp.end(),ftemp.begin(),ftemp.end(),inserter(v, v.begin()));
//cout<<"set_difference works"<<endl;
sort(v.begin(),v.end());
for (it=v.begin(); it!=v.end(); ++it)
{
temp<<*it<<endl;
}
}
void missingfileprocedure(string filename, string filename1, string outputfile)
{
fstream file;
fstream file1;
file.open(filename.c_str(),fstream::in|fstream::out);
file1.open(filename1.c_str(),fstream::in|fstream::out);
int nooffilelist=0;
int nooffilelist1=0;
vector<string> filelist;
vector<string> filelist1;
fstream tfile;
//fstream tfile1;
tfile.open(outputfile.c_str(),fstream::in|fstream::out|fstream::trunc);
filelist = updatevector(file,nooffilelist);
cout<<filename<<" list vector updated"<<endl;
filelist1 = updatevector(file1,nooffilelist1);
cout<<filename1<<" list vector updated"<<endl;
missingfile(tfile,filelist,filelist1);
cout<<outputfile<<" is created"<<endl;
tfile.close();
file.close();
file1.close();
}
int main()
{
missingfileprocedure("todownloadtno.txt","tnolist.txt","missingtnolist.txt");
missingfileprocedure("tnolist.txt","tnofcorrectfilelist.txt","missingtnofcorrectfilelist.txt");
missingfileprocedure("tnolist.txt","tnoferrorfilelist.txt","missingtnoferrorfilelist.txt");
missingfileprocedure("tnoferrorfilelist.txt","tnoserrorfilelist.txt","missingtnoserrorfilelist.txt");
missingfileprocedure("tnofcorrectfilelist.txt","tnoscorrectfilelist.txt","missingtnoscorrectfilelist.txt");
return 0;
}