我有一个GDataOutputStream*,现在我需要手动关闭底层的GOutputStream* (通过调用g_output_stream_close())。
将GDataOutputStream*转换为GOutputStream*是否安全?或者我需要以其他方式获取底层流?
发布于 2019-05-10 18:41:16
是的,这是做事情的正确方式:
g_autoptr(GError) local_error = NULL;
if (!g_output_stream_close (G_OUTPUT_STREAM (my_data_stream), NULL, &local_error))
{
/* handle the error, for example: */
g_warning ("Error closing stream: %s", local_error->message);
}https://stackoverflow.com/questions/56073859
复制相似问题