first commit, base client with gtk3
This commit is contained in:
32
read_uses.cpp
Normal file
32
read_uses.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "read_uses.h"
|
||||
|
||||
read_uses::read_uses(std::string name)
|
||||
{
|
||||
size_t pos=name.find("/");
|
||||
if(pos==std::string::npos){
|
||||
this->short_name=name;
|
||||
}else{
|
||||
this->short_name=name.substr(pos, name.size());
|
||||
}
|
||||
this->file=std::ifstream("/etc/portage/package.use/"+this->short_name, std::ifstream::in);
|
||||
this->exist = file.good();
|
||||
}
|
||||
|
||||
std::string* read_uses::get_uses(){
|
||||
std::string *ret=nullptr;
|
||||
if(this->exist){
|
||||
ret=new std::string;
|
||||
std::string line;
|
||||
while(std::getline(file, line)){
|
||||
std::string no_coment=line.substr(0,line.find("#"));
|
||||
std::size_t found=no_coment.find(this->short_name);
|
||||
if(found!=std::string::npos){
|
||||
found=no_coment.find(this->short_name);
|
||||
if(found!=std::string::npos){
|
||||
*ret=no_coment.substr(0, no_coment.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user