Exemple #1
0
String RenameDialog::_apply_rename(const Node *node, int count) {

	String search = lne_search->get_text();
	String replace = lne_replace->get_text();
	String prefix = lne_prefix->get_text();
	String suffix = lne_suffix->get_text();
	String new_name = node->get_name();

	if (cbut_substitute->is_pressed()) {
		search = _substitute(search, node, count);
		replace = _substitute(replace, node, count);
		prefix = _substitute(prefix, node, count);
		suffix = _substitute(suffix, node, count);
	}

	if (cbut_regex->is_pressed()) {

		new_name = _regex(search, new_name, replace);
	} else {
		new_name = new_name.replace(search, replace);
	}

	new_name = prefix + new_name + suffix;

	if (cbut_process->is_pressed()) {
		new_name = _postprocess(new_name);
	}

	return new_name;
}
Exemple #2
0
std::string FTP::pwd()
{
    std::string resp = sendcmd("PWD");
    std::string pattern = "\"(.*)\"";
    std::vector<std::string> dir;
    
    if(_regex(resp, pattern, 2, dir) < 0) {
        throw error_proto("Unexpected reply to PWD command :\n" +resp);
    }
    return dir[1];
}
Exemple #3
0
void FTP::_getAddress(const std::string& resp, std::string& ip, socketpp::port_t& port)
{
    std::vector<std::string> tok;
    std::string pattern = "\\(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])," \
                          "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])," \
                          "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])," \
                          "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])," \
                          "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])," \
                          "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\)";
    
    if(_regex(resp, pattern, 7, tok) < 0) {
        throw error_proto("Unexpected reply to PASV command :\n" +resp);
    }
    ip = tok[1] +"."+ tok[2]+"."+tok[3]+"."+tok[4];
    port = (atoi(tok[5].c_str()) <<8) + atoi(tok[6].c_str());
}
Exemple #4
0
String RenameDialog::_postprocess(const String &subject) {

	int style_id = opt_style->get_selected();

	String result = subject;

	if (style_id == 1) {

		// CamelCase to Under_Line
		result = result.camelcase_to_underscore(true);
		result = _regex("_+", result, "_");

	} else if (style_id == 2) {

		// Under_Line to CamelCase
		RegEx pattern("_+(.?)");
		Array matches = pattern.search_all(result);

		// _ name would become empty. Ignore
		if (matches.size() && result != "_") {
			String buffer;
			int start = 0;
			int end = 0;
			for (int i = 0; i < matches.size(); ++i) {
				start = ((Ref<RegExMatch>)matches[i])->get_start(1);
				buffer += result.substr(end, start - end - 1);
				buffer += result.substr(start, 1).to_upper();
				end = start + 1;
			}
			buffer += result.substr(end, result.size() - (end + 1));
			result = buffer.replace("_", "").capitalize();
		}
	}

	int case_id = opt_case->get_selected();

	if (case_id == 1) {
		// To Lowercase
		result = result.to_lower();
	} else if (case_id == 2) {
		// To Upercase
		result = result.to_upper();
	}

	return result;
}