1/* Copyright (C) 2007 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <giomm/fileinfo.h>
18#include <giomm/inputstream.h>
19#include <giomm/seekable.h>
20#include <glibmm/iochannel.h>
21#include <glibmm/object.h>
22
23_DEFS(giomm,gio)
24_PINCLUDE(giomm/private/inputstream_p.h)
25
26namespace Gio
27{
28
29/** FileInputStream provides input streams that take their content from a file.
30 *
31 * FileInputStream implements Seekable, which allows the input stream to jump to arbitrary positions in the file,
32 * provided the file system of the file allows it.
33 * Use the methods of the Seekable base class for seeking and positioning.
34 *
35 * @ingroup Streams
36 *
37 * @newin{2,16}
38 */
39class GIOMM_API FileInputStream
40: public Gio::InputStream,
41  public Seekable
42{
43  _CLASS_GOBJECT(FileInputStream, GFileInputStream, G_FILE_INPUT_STREAM, Gio::InputStream, GInputStream, , , GIOMM_API)
44  _IMPLEMENTS_INTERFACE(Seekable)
45
46public:
47
48  /** Queries a file input stream the given @a attributes. This function blocks
49   * while querying the stream. For the asynchronous (non-blocking) version
50   * of this function, see query_info_async(). While the
51   * stream is blocked, the stream will set the pending flag internally, and
52   * any other operations on the stream will throw a Gio::Error with PENDING.
53   *
54   * @param attributes A file attribute query string.
55   * @param cancellable A Cancellable object.
56   * @return A FileInfo, or an empty RefPtr on error.
57   */
58  Glib::RefPtr<FileInfo> query_info(const Glib::RefPtr<Cancellable>& cancellable, const std::string& attributes = "*");
59
60  /** Queries a file input stream the given @a attributes. This function blocks
61   * while querying the stream. For the asynchronous (non-blocking) version
62   * of this function, see query_info_async(). While the
63   * stream is blocked, the stream will set the pending flag internally, and
64   * any other operations on the stream will throw a Gio::Error with PENDING.
65   *
66   * @param attributes A file attribute query string.
67   * @return A FileInfo, or an empty RefPtr on error.
68   */
69  Glib::RefPtr<FileInfo> query_info(const std::string& attributes = "*");
70  _IGNORE(g_file_input_stream_query_info)
71
72
73  /** Queries the stream information asynchronously. For the synchronous version of this function, see query_info().
74   *
75   * The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled,
76   * a Gio::Error with CANCELLED will be thrown.
77   *
78   * When the operation is finished, @a slot will be called. You can then call query_info_finish() to get the result of the operation.
79   *
80   * @param slot A callback slot which will be called when the request is satisfied.
81   * @param cancellable A Cancellable object which can be used to cancel the operation.
82   * @param attributes A file attribute query string.
83   * @param io_priority The I/O priority of the request.
84   */
85  void query_info_async(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, const std::string& attributes = "*", int io_priority = Glib::PRIORITY_DEFAULT);
86
87  /** Queries the stream information asynchronously. For the synchronous version of this function, see query_info().
88   *
89   * When the operation is finished, @a slot will be called. You can then call query_info_finish() to get the result of the operation.
90   *
91   * @param slot A callback slot which will be called when the request is satisfied.
92   * @param attributes A file attribute query string.
93   * @param io_priority The I/O priority of the request.
94   */
95  void query_info_async(const SlotAsyncReady& slot, const std::string& attributes = "*", int io_priority = Glib::PRIORITY_DEFAULT);
96
97  _IGNORE(g_file_input_stream_query_info_async)
98
99  _WRAP_METHOD(Glib::RefPtr<FileInfo> query_info_finish(const Glib::RefPtr<AsyncResult>& result),
100               g_file_input_stream_query_info_finish,
101               errthrow)
102};
103
104} // namespace Gio
105
106