1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <com/sun/star/io/NotConnectedException.hpp>
23 #include <cppuhelper/queryinterface.hxx>
25 #include "gio_outputstream.hxx"
26 #include "gio_content.hxx"
31 OutputStream::OutputStream(GFileOutputStream
*pStream
) : Seekable(G_SEEKABLE(pStream
)), mpStream(pStream
)
34 throw css::io::NotConnectedException();
37 OutputStream::~OutputStream()
42 void SAL_CALL
OutputStream::writeBytes( const css::uno::Sequence
< sal_Int8
>& rData
)
45 throw css::io::NotConnectedException();
47 GError
*pError
=nullptr;
48 if (!g_output_stream_write_all(G_OUTPUT_STREAM(mpStream
), rData
.getConstArray(), rData
.getLength(), nullptr, nullptr, &pError
))
49 convertToIOException(pError
, static_cast< cppu::OWeakObject
* >(this));
52 void SAL_CALL
OutputStream::flush()
55 throw css::io::NotConnectedException();
57 GError
*pError
=nullptr;
58 if (!g_output_stream_flush(G_OUTPUT_STREAM(mpStream
), nullptr, &pError
))
59 convertToIOException(pError
, static_cast< cppu::OWeakObject
* >(this));
62 void SAL_CALL
OutputStream::closeOutput()
65 g_output_stream_close(G_OUTPUT_STREAM(mpStream
), nullptr, nullptr);
68 css::uno::Any
OutputStream::queryInterface( const css::uno::Type
&type
)
70 css::uno::Any aRet
= ::cppu::queryInterface ( type
,
71 static_cast< XOutputStream
* >( this ) );
73 return aRet
.hasValue() ? aRet
: Seekable::queryInterface( type
);
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */