From 5b8ff61799300cf3f56c1db9c990e4a43a63c15d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 19 Feb 2019 12:37:53 +0100 Subject: [PATCH] fs/io/BufferedOutputStream: add WithBufferedOutputStream() --- src/fs/io/BufferedOutputStream.hxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/fs/io/BufferedOutputStream.hxx b/src/fs/io/BufferedOutputStream.hxx index 1df1c5dac..0541817f7 100644 --- a/src/fs/io/BufferedOutputStream.hxx +++ b/src/fs/io/BufferedOutputStream.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2018 Max Kellermann + * Copyright 2014-2019 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -88,4 +88,13 @@ private: #endif }; +template +void +WithBufferedOutputStream(OutputStream &os, F &&f) +{ + BufferedOutputStream bos(os); + f(bos); + bos.Flush(); +} + #endif