-
Notifications
You must be signed in to change notification settings - Fork 0
/
debiancontrolfile.cpp
82 lines (64 loc) · 1.61 KB
/
debiancontrolfile.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "debiancontrolfile.h"
#include <iostream>
#include <fstream>
debianControlFile::debianControlFile(std::string file)
{
fileName=file;
readFile();
}
std::vector<std::string> debianControlFile::getBuildDependencies()
{
return buildDep;
}
void debianControlFile::readFile()
{
std::ifstream f;
std::string line, tmpStr;
size_t iPos=0;
size_t iPos2=0;
bool buildDepBkl=false;
f=std::ifstream(fileName, std::ifstream::in);
while (!f.eof())
{
std::getline(f, line);
if (line.length()==0)
continue;
if (!buildDepBkl)
{
iPos=line.find("Build-Depends:");
if (iPos==0)
{
buildDepBkl=true;
//package names could be named in this line
line=line.substr(14);
if (line.length()==0)
continue;
}
}
if (buildDepBkl)
{
if (line[0]!=' ')
{
//end of block
buildDepBkl=false;
continue;
}
iPos=0;
iPos2=line.find(",");
while (iPos2 < line.length())
{
tmpStr=line.substr(iPos+1,iPos2-iPos-1);
buildDep.push_back(tmpStr);
iPos=iPos2+1;
iPos2=line.find(",",iPos);
}
if (iPos+1<line.length())
{
tmpStr=line.substr(iPos+1);
if (tmpStr.length()>0)
buildDep.push_back(tmpStr);
}
}
}
f.close();
}