Beispiel #1
0
void write_batch_file(const string& batch_file_name, bimap<string, string>& hash_file) {
    ofstream batch(batch_file_name, ios_base::app);

    for (recursive_directory_iterator i(initial_path()), end; i != end; ++i) {
        const string f = i->path().string().substr(initial_path().string().size() + 1);

        if (!is_regular_file(i->path()) || f == batch_file_name || hash_file.right.find(f) != hash_file.right.end()) {
            continue;
        }

        const string h = hexify(sha256(read_file(f)));

        const bimap<string, string>::left_const_iterator j = hash_file.left.find(h);

        if (j == hash_file.left.end()) {
            hash_file.insert(bimap<string, string>::value_type(h, f));

            batch << "@REM " << h << " " << f << endl;
        } else {
            cout << "del \"" << f << "\"" << endl;

            batch << "@copy \"" << j->second << "\" \"" << f << "\"" << endl;
        }
    }

    batch << "@REM **********" << endl;
}
Beispiel #2
0
void read_batch_file(const string& batch_file_name, bimap<string, string>& hash_file) {
    ifstream batch(batch_file_name);

    const regex r("@REM ([[:xdigit:]]{64}) (.+)");

    for (string s; getline(batch, s); ) {
        smatch m;

        if (regex_match(s, m, r)) {
            hash_file.insert(bimap<string, string>::value_type(m[1], m[2]));
        }
    }
}
	void emplace(WordId id, std::wstring word){	id_word_.insert(bimap::value_type(id, std::make_shared<std::wstring>(word))); }
	void emplace(WordId id, C_WStrPtr word){ id_word_.insert(bimap::value_type(id, word)); }