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 <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
21 #include <ucbhelper/cancelcommandexecution.hxx>
24 #include "gio_inputstream.hxx"
25 #include "gio_content.hxx"
27 using namespace com::sun::star
;
32 InputStream::InputStream(GFileInputStream
*pStream
): mpStream(pStream
)
35 throw io::NotConnectedException();
38 InputStream::~InputStream()
43 sal_Int32 SAL_CALL
InputStream::available()
44 throw( io::NotConnectedException
, io::IOException
, uno::RuntimeException
, std::exception
)
49 void SAL_CALL
InputStream::closeInput()
50 throw( io::NotConnectedException
, io::IOException
, uno::RuntimeException
, std::exception
)
53 g_input_stream_close(G_INPUT_STREAM(mpStream
), NULL
, NULL
);
56 void SAL_CALL
InputStream::skipBytes( sal_Int32 nBytesToSkip
)
57 throw( io::NotConnectedException
, io::BufferSizeExceededException
,
58 io::IOException
, uno::RuntimeException
, std::exception
)
60 // Conservatively call readBytes and discard the read data, but given this
61 // InputStream will always be wrapped in comphelper::OSeekableInputWrapper,
62 // this function will never be called anyway:
63 css::uno::Sequence
<sal_Int8
> data
;
64 readBytes(data
, nBytesToSkip
);
67 sal_Int32 SAL_CALL
InputStream::readBytes( uno::Sequence
< sal_Int8
>& aData
, sal_Int32 nBytesToRead
)
68 throw( io::NotConnectedException
, io::BufferSizeExceededException
,
69 io::IOException
, uno::RuntimeException
, std::exception
)
72 throw io::NotConnectedException();
76 aData
.realloc( nBytesToRead
);
78 catch ( const uno::Exception
& )
80 throw io::BufferSizeExceededException();
85 if (!g_input_stream_read_all(G_INPUT_STREAM(mpStream
), aData
.getArray(), nBytesToRead
, &nBytesRead
, NULL
, &pError
))
86 convertToIOException(pError
, static_cast< cppu::OWeakObject
* >(this));
87 aData
.realloc(nBytesRead
);
91 sal_Int32 SAL_CALL
InputStream::readSomeBytes( uno::Sequence
< sal_Int8
>& aData
, sal_Int32 nMaxBytesToRead
)
92 throw( io::NotConnectedException
, io::BufferSizeExceededException
,
93 io::IOException
, uno::RuntimeException
, std::exception
)
95 return readBytes(aData
, nMaxBytesToRead
);
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */