44 #define ERR_CFG LOG_STREAM(err , log_config)
45 #define LOG_CFG LOG_STREAM(info, log_config)
46 #define WRN_CFG LOG_STREAM(warn, log_config)
49 #define ERR_FS LOG_STREAM(err , log_filesystem)
52 #define ERR_NET LOG_STREAM(err , log_network)
53 #define LOG_NET LOG_STREAM(info, log_network)
60 const std::string exterior = parentd +
"/" + addon_name +
".pbl";
61 const std::string interior = parentd +
"/" + addon_name +
"/_server.pbl";
87 const std::string& pbl_path = get_pbl_file_path(addon_name);
109 const std::string& info_path = get_info_file_path(addon_name);
114 ERR_CFG <<
"Failed to read add-on installation information for '"
115 << addon_name <<
"' from " << info_path <<
":\n"
124 LOG_CFG <<
"removing local add-on: " << addon <<
'\n';
127 ERR_CFG <<
"Failed to delete directory/file: " << addon_dir <<
'\n';
128 ERR_CFG <<
"removal of add-on " << addon <<
" failed!" << std::endl;
136 std::vector<std::string>
res;
137 std::vector<std::string> files, dirs;
141 for(std::vector<std::string>::const_iterator
i = dirs.begin();
i != dirs.end(); ++
i) {
152 std::vector<std::string>
res;
154 std::vector<std::string> files, dirs;
157 for(std::vector<std::string>::const_iterator
i = dirs.begin();
i != dirs.end(); ++
i) {
172 static inline bool IsCR(
const char&
c)
182 str.erase(new_end, str.end());
187 void append_default_ignore_patterns(std::pair<std::vector<std::string>, std::vector<std::string> >& patterns)
189 std::vector<std::string>& files = patterns.first;
190 std::vector<std::string>& dirs = patterns.second;
194 files.push_back(
".*");
195 dirs.push_back(
".*");
197 dirs.push_back(
"__MACOSX");
199 files.push_back(
"#*#");
200 files.push_back(
"*~");
201 files.push_back(
"*-bak");
202 files.push_back(
"*.swp");
203 files.push_back(
"*.pbl");
204 files.push_back(
"*.ign");
205 files.push_back(
"_info.cfg");
206 files.push_back(
"*.exe");
207 files.push_back(
"*.bat");
208 files.push_back(
"*.cmd");
209 files.push_back(
"*.com");
210 files.push_back(
"*.scr");
211 files.push_back(
"*.sh");
212 files.push_back(
"*.js");
213 files.push_back(
"*.vbs");
214 files.push_back(
"*.o");
216 files.push_back(
"Thumbs.db");
218 files.push_back(
"*.wesnoth");
219 files.push_back(
"*.project");
226 const std::string ign_file = parentd +
"/" + addon_name +
"/_server.ign";
228 std::pair<std::vector<std::string>, std::vector<std::string> > patterns;
229 LOG_CFG <<
"searching for .ign file for '" << addon_name <<
"'...\n";
231 LOG_CFG <<
"no .ign file found for '" << addon_name <<
"'\n"
232 <<
"inserting default ignore patterns...\n";
233 append_default_ignore_patterns(patterns);
236 LOG_CFG <<
"found .ign file: " << ign_file <<
'\n';
239 while (std::getline(*stream, line)) {
241 const size_t l = line.size();
243 if (l == 0 || !line.compare(0,2,
"# "))
continue;
244 if (line[l - 1] ==
'/') {
245 patterns.second.push_back(line.substr(0, l - 1));
247 patterns.first.push_back(line);
256 const bool is_cfg = (fname.size() > 4 ? (fname.substr(fname.size() - 4) ==
".cfg") :
false);
262 cfg[
"name"] = dirname;
265 std::vector<std::string> files, dirs;
267 for(std::vector<std::string>::const_iterator
i = files.begin();
i != files.end(); ++
i) {
269 for(std::vector<std::string>::const_iterator
p = ignore_patterns.first.begin();
p != ignore_patterns.first.end(); ++
p) {
280 for(std::vector<std::string>::const_iterator j = dirs.begin(); j != dirs.end(); ++j) {
282 for(std::vector<std::string>::const_iterator
p = ignore_patterns.second.begin();
p != ignore_patterns.second.end(); ++
p) {
298 std::pair<std::vector<std::string>, std::vector<std::string> > ignore_patterns;
311 if (cfg[
"name"].empty())
314 dir = path +
'/' + cfg[
"name"].str();
334 std::map< std::string, version_info > version_info_cache;
339 version_info_cache.clear();
341 LOG_CFG <<
"refreshing add-on versions cache\n";
348 std::vector<std::string> addon_info_files(addons.size());
351 addon_info_files.begin(), get_info_file_path);
353 for(
size_t i = 0;
i < addon_info_files.size(); ++
i) {
354 assert(
i < addons.size());
369 LOG_CFG <<
"cached add-on version: " << addon <<
" [" << version <<
"]\n";
371 version_info_cache[addon] =
version;
374 WRN_CFG <<
"add-on '" << addon <<
"' has no _info.cfg; cannot read version info" << std::endl;
383 return entry != version_info_cache.end() ? entry->second : nil;
child_itors child_range(const std::string &key)
bool looks_like_pbl(const std::string &file)
Exception thrown when the WML parser fails to read a .pbl file.
std::string encode_binary(const std::string &str)
std::string unencode_binary(const std::string &str)
bool is_addon_installed(const std::string &addon_name)
Check whether the specified add-on is currently installed.
static bool IsCR(const char &c)
bool wildcard_string_match(const std::string &str, const std::string &match)
Match using '*' as any number of characters (including none), and '?' as any one character.
void get_addon_install_info(const std::string &addon_name, config &cfg)
Gets the installation info (_info.cfg) for an add-on.
static std::string strip_cr(std::string str, bool strip)
static lg::log_domain log_network("network")
bool have_addon_in_vcs_tree(const std::string &addon_name)
Returns true if the specified add-ons appear to be managed by a 'supported' VCS.
version_info get_addon_version_info(const std::string &addon)
Returns a particular installed add-on's version information.
std::vector< std::string > available_addons()
Returns a list of local add-ons that can be published.
std::string & strip(std::string &str)
Remove whitespace from the front and back of the string 'str'.
GLuint GLenum GLenum transform
bool have_addon_install_info(const std::string &addon_name)
Returns true if there is a local installation info (_info.cfg) file for the add-on.
static void archive_file(const std::string &path, const std::string &fname, config &cfg)
GLsizei const char ** path
static void unarchive_file(const std::string &path, const config &cfg)
void write_file(const std::string &fname, const std::string &data)
Throws io_exception if an error occurs.
std::istream * istream_file(const std::string &fname, bool treat_failure_as_error=true)
void set_addon_pbl_info(const std::string &addon_name, const config &cfg)
std::ostream * ostream_file(std::string const &fname, bool create_directory=true)
config & add_child(const std::string &key)
std::vector< std::string > installed_addons()
Retrieves the names of all installed add-ons.
void refresh_addon_version_info_cache()
Refreshes the per-session cache of add-on's version information structs.
bool remove_local_addon(const std::string &addon)
std::string read_file(const std::string &fname)
Basic disk I/O - read file.
static lg::log_domain log_filesystem("filesystem")
void get_files_in_dir(const std::string &dir, std::vector< std::string > *files, std::vector< std::string > *dirs=nullptr, file_name_option mode=FILE_NAME_ONLY, file_filter_option filter=NO_FILTER, file_reorder_option reorder=DONT_REORDER, file_tree_checksum *checksum=nullptr)
Populates 'files' with all the files and 'dirs' with all the directories in dir.
bool have_addon_pbl_info(const std::string &addon_name)
Returns true if there's a local .pbl file stored for the specified add-on.
void archive_addon(const std::string &addon_name, config &cfg)
Archives an add-on into a config object for campaignd transactions.
static lg::log_domain log_config("config")
bool make_directory(const std::string &dirname)
Declarations for File-IO.
void read(config &cfg, std::istream &in, abstract_validator *validator)
Represents version numbers.
bool delete_directory(const std::string &dirname, const bool keep_pbl=false)
void get_addon_pbl_info(const std::string &addon_name, config &cfg)
Gets the publish information for an add-on.
void unarchive_addon(const config &cfg)
std::string get_addons_dir()
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
Standard logging facilities (interface).
static std::pair< std::vector< std::string >, std::vector< std::string > > read_ignore_patterns(const std::string &addon_name)
A config object defines a single node in a WML file, with access to child nodes.
Interfaces for manipulating version numbers of engine, add-ons, etc.
bool file_exists(const std::string &name)
Returns true if a file or directory with such name already exists.
void write(std::ostream &out, configr_of const &cfg, unsigned int level)
const std::string version
GLsizei const GLcharARB ** string
static void unarchive_dir(const std::string &path, const config &cfg)
static void archive_dir(const std::string &path, const std::string &dirname, config &cfg, std::pair< std::vector< std::string >, std::vector< std::string > > &ignore_patterns)
const std::string valid
Little parts of regex templates used to parse Wml annoations.