MCPcopy Create free account
hub / github.com/AGWA/git-crypt / xsputn

Method xsputn

fhstream.cpp:85–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85std::streamsize ofhbuf::xsputn (const char* s, std::streamsize n)
86{
87 // Use heuristic to decide whether to write directly or just use buffer
88 // Write directly only if n >= MIN(4096, available buffer capacity)
89 // (this is similar to what basic_filebuf does)
90
91 if (n < std::min<std::streamsize>(4096, epptr() - pptr())) {
92 // Not worth it to do a direct write
93 return std::streambuf::xsputn(s, n);
94 }
95
96 // Before we can do a direct write of this string, we need to flush
97 // out the current contents of the buffer.
98 if (pbase() != pptr()) {
99 overflow(traits_type::eof()); // throws an exception or it succeeds
100 }
101
102 // Now we can go ahead and write out the string.
103 size_t bytes_to_write = n;
104
105 while (bytes_to_write > 0) {
106 const size_t bytes_written = write_fun(handle, s, bytes_to_write);
107 bytes_to_write -= bytes_written;
108 s += bytes_written;
109 }
110
111 return n; // Return the total bytes written
112}
113
114std::streambuf* ofhbuf::setbuf (char* s, std::streamsize n)
115{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected