#Where is std::ostream::gcount()???
25 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
What does it mean
it says it in the post
check the streambuf directly if you wanna mimic it
use sputn, rdbuf that spits back to the count of chars written
or, for file streams, grab tellp before and after you write
substract to get the diff.. assuming its seekable
how do you access this thing in a
std::ofstream writer("f.txt");
?
there is no direct gcount for output
thats input territory
but to get how many bytes actually hit the file grab the streambuf and use sputn
gcount means get count
so you mean
char rawData[1024];
init(&rawData);
size_t bytesWritten = f.rdbuf()->sputn(rawData, sizeof(rawData));
this?
what for do you need the count in particular? a write either succeeds, i.e., writes as much as you told it to write, or it fails?
if a pipe has 30 bytes available out of 4096 total capacity, and I forcefully write 1024 bytes in it, will it successfully write the first 30 bytes, and then I need to manually issue a second write and then block (that is exactly what pipe() linux man page says), or will it block without writing 30 bytes? that's why
check my last post about popen, I gave up and used fwrite
k ^^
oh and, due to fopen's internal buffer and flushing, a.k.a. write(1, buff, dataLen) runs, GOD knows when, this gets more complicated
yeah. tbh, I'd just use the plain posix functions for stuff like pipes.
ye, good thing I know the raw system calls lmao
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
oh and,
my beloved strace
can reveal black box binaries' write() calls to stdout fd 1