Beispiel #1
0
  void unpack(StreamPtr input,
              StreamFactoryPtr out,
              Progress *prog = NULL,
              const FileList *list = NULL)
  {
    StreamPtr s;

    out->open("test1.dummy.empty");
    s = out->open("test2.txt");
    assert(s);
    s->write("Hello dolly\n", 12);
    s.reset();
    s = out->open("dir1/");
    //assert(!s);
    s = out->open("dir2/test3.txt");
    s->write("This is Louis, Dolly\n", 21);
  }
Beispiel #2
0
Future<unit> write_all(Reactor& reactor, StreamPtr out, Buffer data) {
    std::shared_ptr<Buffer> datap = std::make_shared<Buffer>(data);
    Completer<unit> completer;

    auto write_ready = [completer, datap, out]() {
        if(datap->size == 0) return;

        size_t len = out->write(*datap);
        *datap = datap->slice(len);

        if(datap->size == 0)
            completer.result(unit());
    };

    out->set_on_write_ready(write_ready);

    reactor.schedule(write_ready);

    return completer.future();
}