Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Bidski opened this issue Aug 12, 2024 · 0 comments
Open

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

Bidski opened this issue Aug 12, 2024 · 0 comments
Labels

Comments

@Bidski
Copy link

Bidski commented Aug 12, 2024

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants