-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfakemessages.cpp
64 lines (58 loc) · 1.49 KB
/
fakemessages.cpp
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
#include "fakemessages.h"
#include <QFile>
#include <QTextStream>
#include <QDebug>
FakeMessages::FakeMessages()
{
}
QList<QString> FakeMessages::generate(QString originalMessage, int n)
{
QList<QString> fakeMsgs;
int extra=0;
int wordcount=100;
int filecount=0;
QString filename;
// QTextStream textStream;
if(n>12000)
{
//error and kill cannot handle more than 12000 bases.
}
else
{
for(int i=0;i<n+extra;i++)
{
if(wordcount==100)
{
filename = "messages/msgfile" + QString::number(filecount)+ ".txt";
filecount++;
}
qDebug() << "the filename to be opened is: " << filename;
QFile textFile(filename);
if(!textFile.open(QFile::ReadOnly | QFile::Text))
{
qDebug() << "could not open file for read";
return fakeMsgs;
}
QTextStream textStream(&textFile);
QString line = textStream.readLine();
if (line.isNull())
{
wordcount=100;
}
else
{
if (line==originalMessage)
{
extra+=1;
}
else
{
fakeMsgs.append(line);
wordcount++;
}
}
}
}
qDebug() << "FakeMessages: Generated messages, returning";
return fakeMsgs;
}