blob: 03f2b40dc5efc20bf9bf9690720142375bbdd16b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#pragma once
#include "buffered.h"
#include <library/cpp/yson_pull/detail/macros.h>
#include <library/cpp/yson_pull/exceptions.h>
#include <cstdio>
namespace NYsonPull {
namespace NDetail {
namespace NOutput {
class TStdioFile: public TBuffered<TStdioFile> {
FILE* file_;
public:
TStdioFile(FILE* file, size_t buffer_size)
: TBuffered<TStdioFile>(buffer_size)
, file_(file)
{
}
void write(TStringBuf data) {
auto nwritten = ::fwrite(data.data(), 1, data.size(), file_);
if (Y_UNLIKELY(static_cast<size_t>(nwritten) != data.size())) {
throw NException::TSystemError();
}
}
};
}
} // namespace NDetail
}
|