static void _configfile (CustomData *data, gboolean writemode) { gchar *filename = g_strdup_printf("file://%s/.4deckradio", g_get_home_dir()); g_print ("config file: %s\n", filename); GFile *file = g_file_new_for_uri (filename); if (TRUE == writemode) { /* Save the last folder locations to ~/.4deckradio */ GString *configstring = g_string_new(""); for (int i=0; i < NUM_PLAYERS; i++) { g_print ("deck %i folder %s\n", i, data[i].last_folder_uri); g_string_append_printf (configstring, "%s\n", data[i].last_folder_uri); } g_file_replace_contents (file, configstring->str, configstring->len, NULL, /* old etag */ FALSE, /* backup */ G_FILE_CREATE_PRIVATE, NULL, /* new etag */ NULL, /* cancellable */ NULL); g_string_free (configstring, TRUE); } else { /* load config file */ GFileInputStream *inputstream = g_file_read (file, NULL, NULL); if (NULL == inputstream) { return; } GDataInputStream *config = g_data_input_stream_new (G_INPUT_STREAM (inputstream)); if (NULL == config) { return; } GError *error = NULL; for (int i = 0; i < NUM_PLAYERS; i++) { gsize length; data[i].last_folder_uri = g_data_input_stream_read_line_utf8(config, &length, NULL, &error); if (NULL != error) { g_print ("Error reading config file: %s\n", error->message); } g_clear_error (&error); g_print ("Will use %s for deck %i\n", data[i].last_folder_uri, i); } g_input_stream_close (G_INPUT_STREAM (config), NULL, NULL); g_input_stream_close (G_INPUT_STREAM (inputstream), NULL, NULL); g_object_unref (config); g_object_unref (inputstream); } g_free (filename); g_object_unref (file); }
void ghb_load_icons() { GHashTableIter iter; gchar *key; GValue *gval; GValue *icons = ghb_resource_get("icons"); ghb_dict_iter_init(&iter, icons); // middle (void*) cast prevents gcc warning "defreferencing type-punned // pointer will break strict-aliasing rules" while (g_hash_table_iter_next( &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) { ghb_rawdata_t *rd; gint size; GdkPixbuf *pb; gboolean svg; char *name = g_strdup(key); char *pos; pos = g_strstr_len(name, -1, "."); if (pos != NULL) *pos = '\0'; GInputStream *gis; svg = ghb_value_boolean(ghb_dict_lookup(gval, "svg")); rd = g_value_get_boxed(ghb_dict_lookup(gval, "data")); if (svg) { int ii; int sizes[] = {16, 22, 24, 32, 48, 64, 128, 256, 0}; for (ii = 0; sizes[ii]; ii++) { gis = g_memory_input_stream_new_from_data(rd->data, rd->size, NULL); pb = gdk_pixbuf_new_from_stream_at_scale(gis, sizes[ii], sizes[ii], TRUE, NULL, NULL); g_input_stream_close(gis, NULL, NULL); size = gdk_pixbuf_get_height(pb); gtk_icon_theme_add_builtin_icon(name, size, pb); g_object_unref(pb); } } else { gis = g_memory_input_stream_new_from_data(rd->data, rd->size, NULL); pb = gdk_pixbuf_new_from_stream(gis, NULL, NULL); g_input_stream_close(gis, NULL, NULL); size = gdk_pixbuf_get_height(pb); gtk_icon_theme_add_builtin_icon(name, size, pb); g_object_unref(pb); } g_free(name); } }
static void read_cb (GObject *source, GAsyncResult *asyncResult, gpointer data) { GMainLoop *loop = (GMainLoop*)data; GInputStream *stream = G_INPUT_STREAM (source); GError *error = NULL; gssize bytes_read = g_input_stream_read_finish (stream, asyncResult, &error); if (error) { debug_printf (1, " failed read: %s\n", error->message); errors++; g_object_unref (stream); g_main_loop_quit (loop); return; } if (!bytes_read) { g_input_stream_close (stream, NULL, &error); g_object_unref (stream); if (error) { debug_printf (1, " failed close: %s\n", error->message); errors++; } g_main_loop_quit (loop); return; } g_input_stream_read_async (stream, buffer, READ_BUFFER_SIZE, G_PRIORITY_DEFAULT, NULL, read_cb, data); }
static GeglRectangle gegl_jpg_load_get_bounding_box (GeglOperation *operation) { gint width, height; GeglProperties *o = GEGL_PROPERTIES (operation); const Babl *format = NULL; GFile *file = NULL; GError *err = NULL; gint status = -1; GInputStream *stream = gegl_gio_open_input_stream(o->uri, o->path, &file, &err); if (!stream) return (GeglRectangle) {0, 0, 0, 0}; status = gegl_jpg_load_query_jpg (stream, &width, &height, &format); g_input_stream_close(stream, NULL, NULL); if (format) gegl_operation_set_format (operation, "output", format); g_object_unref(stream); if (file) g_object_unref(file); if (err || status) return (GeglRectangle) {0, 0, 0, 0}; else return (GeglRectangle) {0, 0, width, height}; }
void gst_gio_base_src_set_stream (GstGioBaseSrc * src, GInputStream * stream) { gboolean success; GError *err = NULL; g_return_if_fail (G_IS_INPUT_STREAM (stream)); g_return_if_fail ((GST_STATE (src) != GST_STATE_PLAYING && GST_STATE (src) != GST_STATE_PAUSED)); if (G_IS_INPUT_STREAM (src->stream)) { GST_DEBUG_OBJECT (src, "closing old stream"); /* FIXME: can block but unfortunately we can't use async operations * here because they require a running main loop */ success = g_input_stream_close (src->stream, src->cancel, &err); if (!success && !gst_gio_error (src, "g_input_stream_close", &err, NULL)) { GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL), ("g_input_stream_close failed: %s", err->message)); g_clear_error (&err); } else if (!success) { GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL), ("g_input_stream_close failed")); } else { GST_DEBUG_OBJECT (src, "g_input_stream_close succeeded"); } g_object_unref (src->stream); src->stream = NULL; } src->stream = stream; }
static void read_file (GFile *scratch_file) { GInputStream *input_stream; GError *error = NULL; gint i; input_stream = (GInputStream *) g_file_read (scratch_file, NULL, &error); if (!input_stream) { g_printerr ("Failed to open scratch file: %s\n", error->message); return; } for (i = 0; i < FILE_SIZE; i += BUFFER_SIZE) { gchar buffer [BUFFER_SIZE]; gsize bytes_read; if (!g_input_stream_read_all (input_stream, buffer, BUFFER_SIZE, &bytes_read, NULL, &error) || bytes_read < BUFFER_SIZE) { g_printerr ("Failed to read back scratch file: %s\n", error->message); g_input_stream_close (input_stream, NULL, NULL); g_object_unref (input_stream); } } g_object_unref (input_stream); }
void ghb_load_icons() { #if GTK_CHECK_VERSION(3, 14, 0) ghb_icons_register_resource(); gtk_icon_theme_add_resource_path(gtk_icon_theme_get_default(), "/fr/handbrake/ghb/icons"); #else ghb_icons_register_resource(); GResource *icon_res = ghb_icons_get_resource(); char ** children = g_resource_enumerate_children(icon_res, "/fr/handbrake/ghb/icons/scalable/apps", 0, NULL); if (children == NULL) { g_warning("No icons in resources!"); return; } int ii; for (ii = 0; children[ii] != NULL; ii++) { char * path; path = g_strdup_printf("/fr/handbrake/ghb/icons/scalable/apps/%s", children[ii]); GBytes *gbytes = g_resource_lookup_data(icon_res, path, 0, NULL); gsize data_size; gconstpointer data = g_bytes_get_data(gbytes, &data_size); g_free(path); char *pos; char *name = g_strdup(children[ii]); pos = g_strstr_len(name, -1, "."); if (pos != NULL) *pos = '\0'; int jj; int sizes[] = {16, 22, 24, 32, 48, 64, 128, 256, 0}; for (jj = 0; sizes[jj]; jj++) { GdkPixbuf *pb; GInputStream *gis; int size; gis = g_memory_input_stream_new_from_data(data, data_size, NULL); pb = gdk_pixbuf_new_from_stream_at_scale(gis, sizes[jj], sizes[jj], TRUE, NULL, NULL); g_input_stream_close(gis, NULL, NULL); size = gdk_pixbuf_get_height(pb); gtk_icon_theme_add_builtin_icon(name, size, pb); g_object_unref(pb); } g_bytes_unref(gbytes); } g_strfreev(children); #endif }
static void uriSchemeRequestCallback(WebKitURISchemeRequest* request, gpointer userData) { URISchemeTest* test = static_cast<URISchemeTest*>(userData); test->m_uriSchemeRequest = request; test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); g_assert(webkit_uri_scheme_request_get_web_view(request) == test->m_webView); GRefPtr<GInputStream> inputStream = adoptGRef(g_memory_input_stream_new()); test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inputStream.get())); const char* scheme = webkit_uri_scheme_request_get_scheme(request); g_assert(scheme); g_assert(test->m_handlersMap.contains(String::fromUTF8(scheme))); if (!g_strcmp0(scheme, "error")) { GUniquePtr<GError> error(g_error_new_literal(g_quark_from_string(errorDomain), errorCode, errorMessage)); webkit_uri_scheme_request_finish_error(request, error.get()); return; } const URISchemeHandler& handler = test->m_handlersMap.get(String::fromUTF8(scheme)); if (!g_strcmp0(scheme, "echo")) { char* replyHTML = g_strdup_printf(handler.reply.data(), webkit_uri_scheme_request_get_path(request)); g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), replyHTML, strlen(replyHTML), g_free); } else if (!g_strcmp0(scheme, "closed")) g_input_stream_close(inputStream.get(), 0, 0); else if (!handler.reply.isNull()) g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), handler.reply.data(), handler.reply.length(), 0); webkit_uri_scheme_request_finish(request, inputStream.get(), handler.replyLength, handler.mimeType.data()); }
void dmap_chunked_message_finished (SoupMessage * message, ChunkData * cd) { g_debug ("Finished sending chunked file."); g_input_stream_close (cd->stream, NULL, NULL); g_free (cd); }
static int gio_fclose (VFSFile * file) { FileData * data = vfs_get_handle (file); GError * error = 0; if (data->iostream) { g_io_stream_close (data->iostream, 0, & error); g_object_unref (data->iostream); CHECK_ERROR ("close", vfs_get_filename (file)); } else if (data->istream) { g_input_stream_close (data->istream, 0, & error); g_object_unref (data->istream); CHECK_ERROR ("close", vfs_get_filename (file)); } else if (data->ostream) { g_output_stream_close (data->ostream, 0, & error); g_object_unref (data->ostream); CHECK_ERROR ("close", vfs_get_filename (file)); } if (data->file) g_object_unref (data->file); return 0; FAILED: if (data->file) g_object_unref (data->file); return -1; }
static gboolean process (GeglOperation *operation, GeglBuffer *output, const GeglRectangle *result, gint level) { GeglProperties *o = GEGL_PROPERTIES (operation); Priv *p = (Priv*) o->user_data; if (p->config != NULL) { if (p->decoder != NULL) { if (decode_from_stream (p->stream, p->decoder) < 0) { g_warning ("failed decoding WebP image file"); cleanup (operation); return FALSE; } g_input_stream_close (G_INPUT_STREAM (p->stream), NULL, NULL); g_clear_object (&p->stream); WebPIDelete (p->decoder); p->decoder = NULL; } gegl_buffer_set (output, result, 0, p->format, p->config->output.u.RGBA.rgba, p->config->output.u.RGBA.stride); } return FALSE; }
static gboolean process (GeglOperation *operation, GeglBuffer *output, const GeglRectangle *result, gint level) { GeglProperties *o = GEGL_PROPERTIES (operation); gint problem; gint width, height; Babl *format = NULL; GError *err = NULL; GFile *infile = NULL; GInputStream *stream = gegl_gio_open_input_stream(o->uri, o->path, &infile, &err); WARN_IF_ERROR(err); problem = gegl_buffer_import_png (output, stream, 0, 0, &width, &height, format, &err); WARN_IF_ERROR(err); g_input_stream_close(stream, NULL, NULL); if (problem) { g_object_unref(infile); g_object_unref(stream); g_warning ("%s failed to open file %s for reading.", G_OBJECT_TYPE_NAME (operation), o->path); return FALSE; } if (infile) g_object_unref(infile); g_object_unref(stream); return TRUE; }
static gboolean gst_gio_base_src_stop (GstBaseSrc * base_src) { GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src); GstGioBaseSrcClass *klass = GST_GIO_BASE_SRC_GET_CLASS (src); gboolean success; GError *err = NULL; if (klass->close_on_stop && G_IS_INPUT_STREAM (src->stream)) { GST_DEBUG_OBJECT (src, "closing stream"); /* FIXME: can block but unfortunately we can't use async operations * here because they require a running main loop */ success = g_input_stream_close (src->stream, src->cancel, &err); if (!success && !gst_gio_error (src, "g_input_stream_close", &err, NULL)) { GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL), ("g_input_stream_close failed: %s", err->message)); g_clear_error (&err); } else if (!success) { GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL), ("g_input_stream_close failed")); } else { GST_DEBUG_OBJECT (src, "g_input_stream_close succeeded"); } g_object_unref (src->stream); src->stream = NULL; } else { g_object_unref (src->stream); src->stream = NULL; } return TRUE; }
static void cleanup(GeglOperation *operation) { GeglProperties *o = GEGL_PROPERTIES (operation); Priv *p = (Priv*) o->user_data; if (p != NULL) { if (p->decoder != NULL) WebPIDelete (p->decoder); p->decoder = NULL; if (p->config != NULL) WebPFreeDecBuffer (&p->config->output); if (p->config != NULL) g_free (p->config); p->config = NULL; if (p->stream != NULL) g_input_stream_close (G_INPUT_STREAM (p->stream), NULL, NULL); if (p->stream != NULL) g_clear_object (&p->stream); if (p->file != NULL) g_clear_object (&p->file); p->width = p->height = 0; p->format = NULL; } }
static GeglRectangle get_bounding_box (GeglOperation *operation) { GeglProperties *o = GEGL_PROPERTIES (operation); GeglRectangle result = {0,0,0,0}; gint width, height; gint status; const Babl * format; GError *err = NULL; GFile *infile = NULL; GInputStream *stream = gegl_gio_open_input_stream(o->uri, o->path, &infile, &err); WARN_IF_ERROR(err); if (!stream) return result; status = query_png(stream, &width, &height, &format, &err); WARN_IF_ERROR(err); g_input_stream_close(stream, NULL, NULL); if (status) { width = 0; height = 0; } gegl_operation_set_format (operation, "output", format); result.width = width; result.height = height; if (infile) g_object_unref(infile); g_object_unref(stream); return result; }
static int gstyle_palette_io_close_cb (void *user_data) { g_assert (G_IS_INPUT_STREAM(user_data)); return g_input_stream_close ((GInputStream *)user_data, NULL, NULL) ? 0 : -1; }
static void test_client_destroy (TestClient *client) { GError *error = NULL; if (client->waiter) async_waiter_destroy (client->waiter); g_output_stream_close (G_OUTPUT_STREAM (client->in), NULL, &error); if (error) { g_warning ("Error closing client stdin: %s", error->message); g_clear_error (&error); } g_object_unref (client->in); g_input_stream_close (G_INPUT_STREAM (client->out), NULL, &error); if (error) { g_warning ("Error closing client stdout: %s", error->message); g_clear_error (&error); } g_object_unref (client->out); g_object_unref (client->cancellable); g_object_unref (client->subprocess); g_main_loop_unref (client->loop); g_free (client->id); g_free (client); }
static gboolean gegl_jpg_load_process (GeglOperation *operation, GeglBuffer *output, const GeglRectangle *result, gint level) { GeglProperties *o = GEGL_PROPERTIES (operation); GFile *file = NULL; GError *err = NULL; gint status = -1; GInputStream *stream = gegl_gio_open_input_stream(o->uri, o->path, &file, &err); if (!stream) return FALSE; status = gegl_jpg_load_buffer_import_jpg(output, stream, 0, 0); g_input_stream_close(stream, NULL, NULL); if (err) { g_warning ("%s failed to open file %s for reading: %s", G_OBJECT_TYPE_NAME (operation), o->path, err->message); g_object_unref(stream); return FALSE; } g_object_unref(stream); return status != 1; }
static int stream_close (CamelStream *stream) { CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream); GError *error = NULL; g_return_val_if_fail (CAMEL_IS_STREAM_VFS (stream) && stream_vfs != NULL, -1); g_return_val_if_fail (stream_vfs->stream != NULL, -1); g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream_vfs->stream) || G_IS_INPUT_STREAM (stream_vfs->stream), -1); if (G_IS_OUTPUT_STREAM (stream_vfs->stream)) g_output_stream_close (G_OUTPUT_STREAM (stream_vfs->stream), NULL, &error); else g_input_stream_close (G_INPUT_STREAM (stream_vfs->stream), NULL, &error); if (error) { g_warning ("%s", error->message); g_error_free (error); return -1; } g_object_unref (stream_vfs->stream); stream_vfs->stream = NULL; return 0; }
GdkPixbuf* utils_download_picture(SoupSession* soup, const gchar* url) { SoupMessage* msg; GdkPixbuf* ret = NULL; GInputStream* input; GError* err = NULL; msg = soup_message_new("GET", url); input = soup_session_send(soup, msg, NULL, &err); if (err) { g_warning("{Utils} Error downloading picture code '%d' message '%s'", err->code, err->message); g_error_free(err); } else { ret = gdk_pixbuf_new_from_stream(input, NULL, NULL); g_input_stream_close(input, NULL, NULL); } g_object_unref(msg); return ret; }
gboolean soup_test_request_close_stream (SoupRequest *req, GInputStream *stream, GCancellable *cancellable, GError **error) { AsyncAsSyncData data; gboolean ok; if (SOUP_IS_SESSION_SYNC (soup_request_get_session (req))) return g_input_stream_close (stream, cancellable, error); data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE); g_input_stream_close_async (stream, G_PRIORITY_DEFAULT, cancellable, async_as_sync_callback, &data); g_main_loop_run (data.loop); ok = g_input_stream_close_finish (stream, data.result, error); g_main_loop_unref (data.loop); g_object_unref (data.result); return ok; }
bool ImageHandler::insertImage(GFile * file, double x, double y) { XOJ_CHECK_TYPE(ImageHandler); GError * err = NULL; GFileInputStream * in = g_file_read(file, NULL, &err); g_object_unref(file); GdkPixbuf * pixbuf = NULL; if (!err) { pixbuf = gdk_pixbuf_new_from_stream(G_INPUT_STREAM(in), NULL, &err); g_input_stream_close(G_INPUT_STREAM(in), NULL, NULL); } else { GtkWidget * dialog = gtk_message_dialog_new((GtkWindow*) *control->getWindow(), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("This image could not be loaded. Error message: %s"), err->message); gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(this->control->getWindow()->getWindow())); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); g_error_free(err); return false; } Image * img = new Image(); img->setX(x); img->setY(y); img->setImage(pixbuf); int width = gdk_pixbuf_get_width(pixbuf); int height = gdk_pixbuf_get_height(pixbuf); gdk_pixbuf_unref(pixbuf); double zoom = 1; PageRef page = view->getPage(); if (x + width > page.getWidth() || y + height > page.getHeight()) { double maxZoomX = (page.getWidth() - x) / width; double maxZoomY = (page.getHeight() - y) / height; if (maxZoomX < maxZoomY) { zoom = maxZoomX; } else { zoom = maxZoomY; } } img->setWidth(width * zoom); img->setHeight(height * zoom); page.getSelectedLayer()->addElement(img); InsertUndoAction * insertUndo = new InsertUndoAction(page, page.getSelectedLayer(), img, view); control->getUndoRedoHandler()->addUndoAction(insertUndo); view->rerenderElement(img); return true; }
static int xml_reader_io_close_cb (void *context) { GInputStream *stream = (GInputStream *)context; g_return_val_if_fail (G_IS_INPUT_STREAM(stream), -1); return g_input_stream_close (stream, NULL, NULL) ? 0 : -1; }
static void update_bookmakrs_data_free (UpdateBookmarksData *data) { g_input_stream_close (data->stream, NULL, NULL); g_object_unref (data->stream); g_string_free (data->file_content, TRUE); g_object_unref (data->browser); g_free (data); }
static gboolean g_resource_file_input_stream_close (GInputStream *stream, GCancellable *cancellable, GError **error) { GResourceFileInputStream *file = G_RESOURCE_FILE_INPUT_STREAM (stream); return g_input_stream_close (file->stream, cancellable, error); }
GdkPixbuf * eel_gdk_pixbuf_load_from_stream_at_size (GInputStream *stream, int size) { char buffer[LOAD_BUFFER_SIZE]; gssize bytes_read; GdkPixbufLoader *loader; GdkPixbuf *pixbuf; gboolean got_eos; g_return_val_if_fail (stream != NULL, NULL); got_eos = FALSE; loader = gdk_pixbuf_loader_new (); if (size > 0) { g_signal_connect (loader, "size-prepared", G_CALLBACK (pixbuf_loader_size_prepared), GINT_TO_POINTER (size)); } while (1) { bytes_read = g_input_stream_read (stream, buffer, sizeof (buffer), NULL, NULL); if (bytes_read < 0) { break; } if (bytes_read == 0) { got_eos = TRUE; break; } if (!gdk_pixbuf_loader_write (loader, buffer, bytes_read, NULL)) { break; } } g_input_stream_close (stream, NULL, NULL); gdk_pixbuf_loader_close (loader, NULL); pixbuf = NULL; if (got_eos) { pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); if (pixbuf != NULL) { g_object_ref (pixbuf); } } g_object_unref (loader); return pixbuf; }
static GFile * get_g_file_with_encrypted_data (GFileInputStream *in_stream, goffset file_size) { GError *err = NULL; GFileIOStream *ostream; gssize read_len; guchar *buf; gsize len_file_data = file_size - SHA512_DIGEST_SIZE; gsize done_size = 0; GFile *tmp_encrypted_file = g_file_new_tmp (NULL, &ostream, &err); if (tmp_encrypted_file == NULL) { g_printerr ("%s\n", err->message); // TODO return NULL; } GFileOutputStream *out_enc_stream = g_file_append_to (tmp_encrypted_file, G_FILE_CREATE_NONE, NULL, &err); if (out_enc_stream == NULL) { g_printerr ("%s\n", err->message); // TODO return NULL; } if (len_file_data < FILE_BUFFER) { buf = g_malloc (len_file_data); g_input_stream_read (G_INPUT_STREAM (in_stream), buf, len_file_data, NULL, &err); g_output_stream_write (G_OUTPUT_STREAM (out_enc_stream), buf, len_file_data, NULL, &err); } else { buf = g_malloc (FILE_BUFFER); while (done_size < len_file_data) { if ((len_file_data - done_size) > FILE_BUFFER) { read_len = g_input_stream_read (G_INPUT_STREAM (in_stream), buf, FILE_BUFFER, NULL, &err); } else { read_len = g_input_stream_read (G_INPUT_STREAM (in_stream), buf, len_file_data - done_size, NULL, &err); } if (read_len == -1) { g_printerr ("%s\n", err->message); // TODO return NULL; } g_output_stream_write (G_OUTPUT_STREAM (out_enc_stream), buf, read_len, NULL, &err); done_size += read_len; memset (buf, 0, FILE_BUFFER); } } g_input_stream_close (G_INPUT_STREAM (in_stream), NULL, NULL); g_output_stream_close (G_OUTPUT_STREAM (out_enc_stream), NULL, NULL); g_object_unref (out_enc_stream); g_free (buf); return tmp_encrypted_file; }
static void g_input_stream_dispose (GObject *object) { GInputStream *stream; stream = G_INPUT_STREAM (object); if (!stream->priv->closed) g_input_stream_close (stream, NULL, NULL); G_OBJECT_CLASS (g_input_stream_parent_class)->dispose (object); }
static GsfInput * make_local_copy (GFile *file, GInputStream *stream) { GsfOutput *out; GsfInput *copy; GFileInfo *info; out = gsf_output_memory_new (); while (1) { guint8 buf[4096]; gssize nread; nread = g_input_stream_read (stream, buf, sizeof(buf), NULL, NULL); if (nread > 0) { if (!gsf_output_write (out, nread, buf)) { copy = NULL; goto cleanup_and_exit; } } else if (nread == 0) break; else { copy = NULL; goto cleanup_and_exit; } } copy = gsf_input_memory_new_clone (gsf_output_memory_get_bytes (GSF_OUTPUT_MEMORY (out)), gsf_output_size (out)); if (copy != NULL) { info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, NULL); if (info) { gsf_input_set_name (GSF_INPUT (copy), g_file_info_get_name (info)); g_object_unref (info); } } cleanup_and_exit: gsf_output_close (out); g_object_unref (out); g_input_stream_close (stream, NULL, NULL); g_object_unref (stream); set_name_from_file (copy, file); return copy; }
GamepadDevice::~GamepadDevice() { close(m_fileDescriptor); if (m_source) g_source_destroy(m_source); if (m_inputStream) g_input_stream_close(m_inputStream, 0, 0); // XXX: maybe there is a cleaner way to do this? memset(m_nixGamepad, 0, sizeof(Nix::Gamepad)); }