Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 137784 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-43 / +72 lines)
Line  Link Here
0
-- src/eixTk/utils.cc
0
++ src/eixTk/utils.cc
Lines 43-49 Link Here
43
using namespace std;
43
using namespace std;
44
44
45
/** push_back every line of file into v. */
45
/** push_back every line of file into v. */
46
bool pushback_lines(const char *file, vector<string> *v, bool removed_empty)
46
bool pushback_lines_file(const char *file, vector<string> *v, bool removed_empty)
47
{
47
{
48
	string line;
48
	string line;
49
	ifstream ifstr(file);
49
	ifstream ifstr(file);
Lines 71-84 Link Here
71
	return false;
71
	return false;
72
}
72
}
73
73
74
/** push_back every line of file or dir into v. */
75
bool pushback_lines(const char *file, vector<string> *v, bool removed_empty, bool recursive)
76
{
77
	static const char *files_exclude[] = { "..", "." , NULL };
78
	vector<string> files;
79
	string dir(file);
80
	dir += "/";
81
	if(recursive && pushback_files(dir, files, files_exclude, false))
82
	{
83
		bool rvalue=true;
84
		for(vector<string>::iterator it=files.begin();
85
			it<files.end(); ++it)
86
		{
87
			if(! pushback_lines(it->c_str(), v, removed_empty))
88
				rvalue=false;
89
		}
90
		return rvalue;
91
	}
92
	else
93
		return pushback_lines_file(file, v, removed_empty);
94
}
95
74
/** List of files in directory.
96
/** List of files in directory.
75
 * Pushed names of file in directory into string-vector if the don't match any
97
 * Pushed names of file in directory into string-vector if the don't match any
76
 * char * in given exlude list.
98
 * char * in given exlude list.
77
 * @param dir_path Path to directory
99
 * @param dir_path Path to directory
78
 * @param into pointer to vector of strings .. files get append here (with full path)
100
 * @param into pointer to vector of strings .. files get append here (with full path)
79
 * @param exclude list of char * that don't need to be put into vector
101
 * @param exclude list of char * that don't need to be put into vector
102
 * @param onlyfiles consider only ordinary files
80
 * @return false if everything is ok */
103
 * @return false if everything is ok */
81
bool pushback_files(string &dir_path, vector<string> &into, const char *exclude[])
104
bool pushback_files(string &dir_path, vector<string> &into, const char *exclude[], bool onlyfiles)
82
{
105
{
83
	struct stat static_stat;
106
	struct stat static_stat;
84
	DIR *dir = opendir(dir_path.c_str());
107
	DIR *dir = opendir(dir_path.c_str());
Lines 91-103 Link Here
91
		if(exclude)
114
		if(exclude)
92
		{
115
		{
93
			char **_p = (char **)exclude;
116
			char **_p = (char **)exclude;
94
			while(*_p) /* Look if it's in exclude */
117
			for(;*_p;_p++) /* Look if it's in exclude */
95
				if(strcmp(*(_p++), dir_entry->d_name) == 0)
118
				if(strcmp(*_p, dir_entry->d_name) == 0)
96
					continue;
119
					break;
120
			if(*_p)
121
				continue;
122
123
		}
124
		if(onlyfiles)
125
		{
126
			if(stat((dir_path + dir_entry->d_name).c_str(), &static_stat)
127
					|| !S_ISREG(static_stat.st_mode))
128
				continue;
97
		}
129
		}
98
		if(stat((dir_path + dir_entry->d_name).c_str(), &static_stat)
99
				|| !S_ISREG(static_stat.st_mode))
100
			continue;
101
		into.push_back(dir_path + dir_entry->d_name);
130
		into.push_back(dir_path + dir_entry->d_name);
102
	}
131
	}
103
	closedir(dir);
132
	closedir(dir);
104
-- src/eixTk/utils.h
133
++ src/eixTk/utils.h
Lines 32-39 Link Here
32
#include <vector>
32
#include <vector>
33
#include <string>
33
#include <string>
34
34
35
/** push_back every line of file into v. */
35
/** push_back every line of file or dir into v. */
36
bool pushback_lines(const char *file, std::vector<std::string> *v, bool removed_empty = true);
36
bool pushback_lines(const char *file, std::vector<std::string> *v, bool removed_empty = true, bool recursive = true);
37
37
38
/** List of files in directory.
38
/** List of files in directory.
39
 * Pushed names of file in directory into string-vector if the don't match any
39
 * Pushed names of file in directory into string-vector if the don't match any
Lines 41-48 Link Here
41
 * @param dir_path Path to directory
41
 * @param dir_path Path to directory
42
 * @param into pointer to vector of strings .. files get append here (with full path)
42
 * @param into pointer to vector of strings .. files get append here (with full path)
43
 * @param exlude list of char * that don't need to be put into vector
43
 * @param exlude list of char * that don't need to be put into vector
44
 * @param onlyfiles consider only ordinary files
44
 * @return false if everything is ok */
45
 * @return false if everything is ok */
45
bool pushback_files(std::string &dir_path, std::vector<std::string> &into, const char *exclude[]);
46
bool pushback_files(std::string &dir_path, std::vector<std::string> &into, const char *exclude[], bool onlyfiles = true);
46
47
47
48
48
/** Cycle through map using it, until it is it_end, append all values from it
49
/** Cycle through map using it, until it is it_end, append all values from it
49
-- src/portage/conf/portagesettings.cc
50
++ src/portage/conf/portagesettings.cc
Lines 42-77 Link Here
42
42
43
using namespace std;
43
using namespace std;
44
44
45
bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map, vector<Mask*> *mask_vec)
45
bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map, vector<Mask*> *mask_vec, bool recursive)
46
{
46
{
47
	ifstream mask_file(file);
47
	vector<string> lines;
48
	if(mask_file.is_open()) {
48
	if( ! pushback_lines(file, &lines, true, recursive))
49
		string line;
49
		return false;
50
		while(getline(mask_file, line)) {
50
	for(vector<string>::iterator it=lines.begin(); it<lines.end(); ++it)
51
			trim(&line);
51
	{
52
			if(line.size() == 0 || line[0] == '#')
52
		string line=*it;
53
				continue;
53
		try {
54
			try {
54
			Mask *m = new Mask(line.c_str(), type);
55
				Mask *m = new Mask(line.c_str(), type);
55
			OOM_ASSERT(m);
56
				OOM_ASSERT(m);
56
			if(cat_map) {
57
				if(cat_map) {
57
				cat_map->add(m);
58
					cat_map->add(m);
59
				}
60
				else {
61
					mask_vec->push_back(m);
62
				}
63
			}
58
			}
64
			catch(ExBasic e) {
59
			else {
65
				cerr << "-- Invalid line in " << file << ": \"" << line << "\"" << endl
60
				mask_vec->push_back(m);
66
				     << "   " << e.getMessage() << endl;
67
			}
61
			}
68
		}
62
		}
69
		mask_file.close();
63
		catch(ExBasic e) {
70
		return true;
64
			cerr << "-- Invalid line in " << file << ": \"" << line << "\"" << endl
65
			     << "   " << e.getMessage() << endl;
66
		}
71
	}
67
	}
72
	return false;
68
	return true;
73
}
69
}
74
70
71
72
73
75
/** Key that should accumelate their content rathern then replace. */
74
/** Key that should accumelate their content rathern then replace. */
76
static const char *default_accumulating_keys[] = {
75
static const char *default_accumulating_keys[] = {
77
	"USE",
76
	"USE",
78
-- src/portage/conf/portagesettings.h
77
++ src/portage/conf/portagesettings.h
Lines 45-60 Link Here
45
class Package;
45
class Package;
46
46
47
/** Grab Masks from file and add to a category->vector<Mask*> mapping or to a vector<Mask*>. */
47
/** Grab Masks from file and add to a category->vector<Mask*> mapping or to a vector<Mask*>. */
48
bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map, std::vector<Mask*> *mask_vec);
48
bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map, std::vector<Mask*> *mask_vec, bool recursive=true);
49
49
50
/** Grab Mask from file and add to category->vector<Mask*>. */
50
/** Grab Mask from file and add to category->vector<Mask*>. */
51
inline bool grab_masks(const char *file, Mask::Type type, std::vector<Mask*> *mask_vec) {
51
inline bool grab_masks(const char *file, Mask::Type type, std::vector<Mask*> *mask_vec, bool recursive=true) {
52
	return grab_masks(file, type, NULL , mask_vec);
52
	return grab_masks(file, type, NULL , mask_vec, recursive);
53
}
53
}
54
54
55
/** Grab Mask from file and add to vector<Mask*>. */
55
/** Grab Mask from file and add to vector<Mask*>. */
56
inline bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map) {
56
inline bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map, bool recursive=true) {
57
	return grab_masks(file, type, cat_map, NULL);
57
	return grab_masks(file, type, cat_map, NULL, recursive);
58
}
58
}
59
59
60
class PortageSettings;
60
class PortageSettings;

Return to bug 137784