You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that when I write to an output file which already exists, it is not truncated:
#include<fmt/os.h>intmain() {
fmt::output_file("/path/to/file").print("AAAAA");
// file contents is "AAAAA"fmt::output_file("/path/to/file").print("BBB");
// file contents is "BBBAA", but it would be nice if it was "BBB"
}
output_file accepts some config flags, so I can hack around with undocumented FMT macros and get it to work how I want like this:
#include<fmt/os.h>intmain() {
fmt::output_file("/path/to/file").print("AAAAA");
// file contents is "AAAAA"fmt::output_file("/path/to/file").print("BBB", fmt::file::WRONLY | fmt::file::CREATE | FMT_POSIX(O_TRUNC));
// file contents is "BBB"
}
Would it be possible to add an fmt::file::TRUNC option?
It might also be worth making that the default. I see no reason why someone would want fmt::file::WRONLY | fmt::file::CREATE (the current default) but be unhappy with fmt::file::WRONLY | fmt::file::CREATE | fmt::file::TRUNC. Although that would be a breaking change.
The text was updated successfully, but these errors were encountered:
It seems that when I write to an output file which already exists, it is not truncated:
output_file
accepts some config flags, so I can hack around with undocumented FMT macros and get it to work how I want like this:Would it be possible to add an
fmt::file::TRUNC
option?It might also be worth making that the default. I see no reason why someone would want
fmt::file::WRONLY | fmt::file::CREATE
(the current default) but be unhappy withfmt::file::WRONLY | fmt::file::CREATE | fmt::file::TRUNC
. Although that would be a breaking change.The text was updated successfully, but these errors were encountered: