#include "handler.ih"

void Handler::saveTheZip(string const &file)
{
//    cerr << "filename: " << file << '\n';

    if (path{ file }.extension() != ".zip")
        throw Exception{REPLY} <<
                "Your attachment is named `" << file << 
                                                "', which doesn't have the\n"
                "required .zip extension. Use the correct zip-name and "
                                                            "resubmit";

    d_zip = file;

    string line;                                // skip through the next
                                                // empty line
    while (getline(cin, line) and not String::trim(line).empty())
        ;

    IBase64Stream<DECRYPT> ib64(cin, 1);

    ofstream out(d_zip);

    out << ib64.rdbuf();
}
