]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/c_glib/arrow-glib/file.cpp
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
20 #include <arrow/api.h>
22 #include <arrow-glib/error.hpp>
23 #include <arrow-glib/file.hpp>
24 #include <arrow-glib/file-mode.hpp>
31 * @short_description: File interface
33 * #GArrowFile is an interface for file.
36 G_DEFINE_INTERFACE(GArrowFile
,
41 garrow_file_default_init(GArrowFileInterface
*iface
)
47 * @file: A #GArrowFile.
48 * @error: (nullable): Return location for a #GError or %NULL.
50 * Returns: %TRUE on success, %FALSE if there was an error.
53 garrow_file_close(GArrowFile
*file
,
56 auto arrow_file
= garrow_file_get_raw(file
);
58 auto status
= arrow_file
->Close();
59 return garrow_error_check(error
, status
, "[io][file][close]");
63 * garrow_file_is_closed:
64 * @file: A #GArrowFile.
66 * Returns: %TRUE if the @file is already closed, %FALSE otherwise.
71 garrow_file_is_closed(GArrowFile
*file
)
73 auto arrow_file
= garrow_file_get_raw(file
);
74 return arrow_file
->closed();
79 * @file: A #GArrowFile.
80 * @error: (nullable): Return location for a #GError or %NULL.
82 * Returns: The current offset on success, -1 if there was an error.
85 garrow_file_tell(GArrowFile
*file
,
88 auto arrow_file
= garrow_file_get_raw(file
);
90 const auto position
= arrow_file
->Tell();
91 if (garrow::check(error
, position
, "[io][file][tell]")) {
92 return position
.ValueOrDie();
99 * garrow_file_get_mode:
100 * @file: A #GArrowFile.
102 * Returns: The mode of the file.
105 garrow_file_get_mode(GArrowFile
*file
)
107 auto arrow_file
= garrow_file_get_raw(file
);
109 auto arrow_mode
= arrow_file
->mode();
110 return garrow_file_mode_from_raw(arrow_mode
);
115 std::shared_ptr
<arrow::io::FileInterface
>
116 garrow_file_get_raw(GArrowFile
*file
)
118 auto *iface
= GARROW_FILE_GET_IFACE(file
);
119 return iface
->get_raw(file
);