blob: d59ea6bfb9ef69673325b5a86089d80a6ef8054b (
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
}
|