| 886 | } |
| 887 | |
| 888 | arrow::Result<int64_t> |
| 889 | GetSize() override |
| 890 | { |
| 891 | if (!G_IS_SEEKABLE(input_stream_)) { |
| 892 | std::string message("[gio-input-stream][size] " |
| 893 | "not seekable input stream: <"); |
| 894 | message += G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(input_stream_)); |
| 895 | message += ">"; |
| 896 | return arrow::Status::NotImplemented(message); |
| 897 | } |
| 898 | |
| 899 | std::lock_guard<std::mutex> guard(lock_); |
| 900 | auto current_position = g_seekable_tell(G_SEEKABLE(input_stream_)); |
| 901 | GError *error = NULL; |
| 902 | if (!g_seekable_seek(G_SEEKABLE(input_stream_), 0, G_SEEK_END, NULL, &error)) { |
| 903 | return garrow_error_to_status(error, |
| 904 | arrow::StatusCode::IOError, |
| 905 | "[gio-input-stream][size][seek]"); |
| 906 | } |
| 907 | auto size = g_seekable_tell(G_SEEKABLE(input_stream_)); |
| 908 | if (!g_seekable_seek(G_SEEKABLE(input_stream_), |
| 909 | current_position, |
| 910 | G_SEEK_SET, |
| 911 | NULL, |
| 912 | &error)) { |
| 913 | return garrow_error_to_status(error, |
| 914 | arrow::StatusCode::IOError, |
| 915 | "[gio-input-stream][size][seek][restore]"); |
| 916 | } |
| 917 | return size; |
| 918 | } |
| 919 | |
| 920 | bool |
| 921 | supports_zero_copy() const override |
no test coverage detected