Huggle  build:^490^dce1e5c
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
main.cpp
1 //This program is free software: you can redistribute it and/or modify
2 //it under the terms of the GNU General Public License as published by
3 //the Free Software Foundation, either version 3 of the License, or
4 //(at your option) any later version.
5 
6 //This program is distributed in the hope that it will be useful,
7 //but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 //GNU General Public License for more details.
10 
11 
12 #include <QCoreApplication>
13 #include <QString>
14 #include <QFile>
15 #include <iostream>
16 
17 int main(int argc, char *argv[])
18 {
19  QCoreApplication a(argc, argv);
20  if (argc < 2)
21  {
22  std::cout << "it would be cool if you gave me makefile path" << std::endl;
23  return 400;
24  }
25  QString f(argv[1]);
26  QFile *file = new QFile(f);
27  if (!file->open(QIODevice::ReadWrite | QIODevice::Text))
28  {
29  std::cout << "unable to open a file" << std::endl;
30  return 400;
31  }
32  QString value(file->readAll());
33  file->close();
34  delete file;
35  file = new QFile(f);
36  if (!file->open(QIODevice::ReadWrite | QIODevice::Truncate))
37  {
38  std::cout << "unable to open a file" << std::endl;
39  return 400;
40  }
41 
42  if (value.contains("install:"))
43  {
44  value = value.mid(0, value.indexOf("install:"));
45  value += QString("\n") + QString("install:\n\t ./build/install\nuninstall:\n\t ./build/uninstall\n\nFORCE:\n");
46  file->write(value.toUtf8());
47  file->close();
48  }
49  delete file;
50  return 0;
51 }