Line |
Branch |
Exec |
Source |
1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : aubertp7@gmail.com |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
#include <stdio.h> |
8 |
|
|
#include <stdlib.h> |
9 |
|
|
#include <iostream> |
10 |
|
|
#include <string> |
11 |
|
|
#include <fstream> |
12 |
|
|
|
13 |
|
|
///Fonction qui permet de suprimer un dossier |
14 |
|
|
/** @param dir : nom du dossier que l'on veut suprimer |
15 |
|
|
* @return true si la fonction a réussie, false sinon |
16 |
|
|
*/ |
17 |
|
✗ |
bool removeDirectory(const std::string & dir){ |
18 |
|
✗ |
std::string commande("rm -rf " + dir); |
19 |
|
✗ |
if(system(commande.c_str()) != 0){ |
20 |
|
✗ |
std::cerr << "can't remove directory '" << dir << "'" << std::endl; |
21 |
|
✗ |
return false; |
22 |
|
|
} |
23 |
|
✗ |
return true; |
24 |
|
|
} |
25 |
|
|
|
26 |
|
✗ |
int main(int argc, char** argv){ |
27 |
|
✗ |
std::string installManifest("/usr/share/Phoenix/uninstall/PhoenixOptionParser/install_manifest.txt"); |
28 |
|
✗ |
std::ifstream fs; |
29 |
|
✗ |
fs.open(installManifest.c_str()); |
30 |
|
✗ |
if(!fs.is_open()){ |
31 |
|
✗ |
std::cerr << "Can't open file '" << installManifest << "'" << std::endl; |
32 |
|
✗ |
return -1; |
33 |
|
|
} |
34 |
|
|
int ch; |
35 |
|
|
do{ |
36 |
|
✗ |
std::string line(""); |
37 |
|
✗ |
ch = fs.get(); |
38 |
|
✗ |
while(ch != EOF && (char)ch != '\n'){ |
39 |
|
✗ |
line += (char)ch; |
40 |
|
✗ |
ch = fs.get(); |
41 |
|
|
} |
42 |
|
✗ |
if(line != ""){ |
43 |
|
✗ |
if(remove(line.c_str()) != 0){ |
44 |
|
✗ |
std::cerr << "Can't remove file '" << line << "'" << std::endl; |
45 |
|
|
}else{ |
46 |
|
✗ |
std::cerr << "Remove file '" << line << "'" << std::endl; |
47 |
|
|
} |
48 |
|
|
} |
49 |
|
✗ |
}while(ch != EOF); |
50 |
|
✗ |
fs.close(); |
51 |
|
✗ |
removeDirectory("/usr/share/Phoenix/uninstall/PhoenixOptionParser"); |
52 |
|
✗ |
std::cerr << "Uninstall all files from the " << std::endl; |
53 |
|
✗ |
return 0; |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|