Skip to content

Using .open() after default construction results in empty file #65

@Bidski

Description

@Bidski

If you default construct a zstr::ofstream object and then use .open() on the same object no data is written to the file.

This code snippet shows this issue. The file test.txt.gz will be empty at the termination of this program

#include <zstr.hpp>

int main(int argc, char** argv) {
    zstr::ofstream ofs{};

    ofs.open("test.txt.gz");
    ofs << "Use: " << argv[0] << " file" << std::endl
        << "Synopsis: Open `file` as a file stream object" << std::endl
        << "Stream Classes:" << std::endl
        << "  std" << std::endl
        << "  std_mask" << std::endl
        << "  strict_fstream" << std::endl
        << "Stream Types:" << std::endl
        << "  ifstream" << std::endl
        << "  ofstream" << std::endl
        << "  fstream" << std::endl
        << "Modes:" << std::endl
        << "  in=" << std::ios_base::in << std::endl
        << "  out=" << std::ios_base::out << std::endl
        << "  app=" << std::ios_base::app << std::endl
        << "  ate=" << std::ios_base::ate << std::endl
        << "  trunc=" << std::ios_base::trunc << std::endl
        << "  binary=" << std::ios_base::binary << std::endl;
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions