int makeWindow(RuskWindow *rusk) { GtkWidget *box; if((rusk->window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL))) == NULL) { return -1; } gtk_container_set_border_width(GTK_CONTAINER(rusk->window), BORDER_WIDTH); gtk_widget_override_background_color(GTK_WIDGET(rusk->window), GTK_STATE_FLAG_NORMAL, BORDER_COLOR_NORMAL); box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_container_add(GTK_CONTAINER(rusk->window), box); rusk->addressbar = GTK_ENTRY(gtk_entry_new()); gtk_entry_set_placeholder_text(rusk->addressbar, "URI"); gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(rusk->addressbar), FALSE, FALSE, 0); rusk->globalSearch = GTK_ENTRY(gtk_search_entry_new()); gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(rusk->globalSearch), FALSE, FALSE, 0); rusk->insiteSearch = GTK_ENTRY(gtk_search_entry_new()); gtk_entry_set_placeholder_text(rusk->insiteSearch, "site search"); gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(rusk->insiteSearch), FALSE, FALSE, 0); rusk->progressbar = GTK_PROGRESS_BAR(gtk_progress_bar_new()); gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(rusk->progressbar), FALSE, FALSE, 0); rusk->webview = WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(webkit_web_context_new_with_website_data_manager(webkit_website_data_manager_new( "base-cache-directory", g_strdup_printf("%s/rusk", g_get_user_cache_dir()), "disk-cache-directory", g_strdup_printf("%s/rusk", g_get_user_cache_dir()), "base-data-directory", g_strdup_printf("%s/rusk/data", g_get_user_data_dir()), "indexeddb-directory", g_strdup_printf("%s/rusk/indexed", g_get_user_data_dir()), "local-storage-directory", g_strdup_printf("%s/rusk/local-storage", g_get_user_data_dir()), "offline-application-cache-directory", g_strdup_printf("%s/rusk/offline-apps", g_get_user_data_dir()), "websql-directory", g_strdup_printf("%s/rusk/websql", g_get_user_data_dir()), NULL )))); gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(rusk->webview), TRUE, TRUE, 0); g_signal_connect(G_OBJECT(rusk->window), "destroy", G_CALLBACK(closeRusk), rusk); gtk_widget_show_all(GTK_WIDGET(rusk->window)); gtk_widget_set_visible(GTK_WIDGET(rusk->addressbar), FALSE); gtk_widget_set_visible(GTK_WIDGET(rusk->globalSearch), FALSE); gtk_widget_set_visible(GTK_WIDGET(rusk->progressbar), FALSE); gtk_widget_set_visible(GTK_WIDGET(rusk->insiteSearch), FALSE); g_signal_connect(G_OBJECT(rusk->window), "key-press-event", G_CALLBACK(onKeyPress), rusk); g_signal_connect(G_OBJECT(rusk->insiteSearch), "search-changed", G_CALLBACK(onInSiteSearchInput), rusk); g_signal_connect(G_OBJECT(rusk->addressbar), "key-release-event", G_CALLBACK(onAddressbarInput), rusk); g_signal_connect(G_OBJECT(rusk->globalSearch), "activate", G_CALLBACK(onGlobalSearchActivate), rusk); return 0; }
static char * xplayer_uri_get_cached_subtitle_for_uri (const char *uri) { char *filename, *basename, *fake_filename, *fake_uri, *ret; filename = g_filename_from_uri (uri, NULL, NULL); if (filename == NULL) return NULL; basename = g_path_get_basename (filename); g_free (filename); if (basename == NULL || strcmp (basename, ".") == 0) { g_free (basename); return NULL; } fake_filename = g_build_filename (g_get_user_cache_dir (), "xplayer", "subtitles", basename, NULL); g_free (basename); fake_uri = g_filename_to_uri (fake_filename, NULL, NULL); g_free (fake_filename); ret = xplayer_uri_get_subtitle_for_uri (fake_uri); g_free (fake_uri); return ret; }
static void pdf_load_job_from_google_documents (PdfLoadJob *job) { gchar *tmp_name; gchar *tmp_path, *pdf_path; GFile *pdf_file; job->original_file_mtime = gdata_entry_get_updated (job->gdata_entry); tmp_name = g_strdup_printf ("gnome-documents-%u.pdf", g_str_hash (gdata_documents_entry_get_resource_id (GDATA_DOCUMENTS_ENTRY (job->gdata_entry)))); tmp_path = g_build_filename (g_get_user_cache_dir (), "gnome-documents", NULL); job->pdf_path = pdf_path = g_build_filename (tmp_path, tmp_name, NULL); g_mkdir_with_parents (tmp_path, 0700); pdf_file = g_file_new_for_path (pdf_path); g_file_query_info_async (pdf_file, G_FILE_ATTRIBUTE_TIME_MODIFIED, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, job->cancellable, gdata_cache_query_info_ready_cb, job); g_free (tmp_name); g_free (tmp_path); g_object_unref (pdf_file); }
G_MODULE_EXPORT void on_cleancache(GtkMenuItem *menu, AWeatherGui *self) { g_debug("AWeatherGui: on_cleancache"); /* Todo: move this to grits */ gchar *cache = g_build_filename(g_get_user_cache_dir(), "grits", NULL); cleancache_r(cache); }
static void metadata_menuitem_clean_album_art_temp_dir (void) { const gchar* _tmp0_ = NULL; gchar* _tmp1_ = NULL; gchar* path; const gchar* _tmp2_; GFile* _tmp3_ = NULL; GFile* album_art_dir; GFile* _tmp4_; gboolean _tmp5_ = FALSE; _tmp0_ = g_get_user_cache_dir (); _tmp1_ = g_build_filename (_tmp0_, METADATA_MENUITEM_ALBUM_ART_DIR_SUFFIX, NULL); path = _tmp1_; _tmp2_ = path; _tmp3_ = g_file_new_for_path (_tmp2_); album_art_dir = _tmp3_; _tmp4_ = album_art_dir; _tmp5_ = metadata_menuitem_delete_album_art_contents (_tmp4_); if (_tmp5_ == FALSE) { const gchar* _tmp6_; _tmp6_ = path; g_warning ("metadata-menu-item.vala:58: could not remove the temp album art files " \ "%s", _tmp6_); } _g_object_unref0 (album_art_dir); _g_free0 (path); }
void log_init (void) { const char *homedir = g_getenv ("HOME"); if (!homedir) homedir = g_get_home_dir (); g_return_if_fail (homedir != NULL); // Make sure the cache directory is there, if at all possible const gchar *dirname = g_get_user_cache_dir (); g_mkdir_with_parents (dirname, 0700); char *filename = g_build_filename (dirname, "notify-osd.log", NULL); logfile = fopen (filename, "w"); if (logfile == NULL) g_warning ("could not open/append to %s; logging disabled", filename); g_free (filename); /* discard all debug messages unless DEBUG is set */ if (! g_getenv ("DEBUG")) g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_logger_null, NULL); g_message ("DEBUG mode enabled"); }
PluginInfoCache::PluginInfoCache() : m_cacheFile(g_key_file_new()) , m_readOnlyMode(false) { GUniquePtr<char> cacheDirectory(g_build_filename(g_get_user_cache_dir(), "webkitgtk", nullptr)); if (WebCore::makeAllDirectories(cacheDirectory.get())) { m_cachePath.reset(g_build_filename(cacheDirectory.get(), "plugins", nullptr)); g_key_file_load_from_file(m_cacheFile.get(), m_cachePath.get(), G_KEY_FILE_NONE, nullptr); } if (g_key_file_has_group(m_cacheFile.get(), "schema")) { unsigned schemaVersion = static_cast<unsigned>(g_key_file_get_integer(m_cacheFile.get(), "schema", "version", nullptr)); if (schemaVersion < gSchemaVersion) { // Cache file using an old schema, create a new empty file. m_cacheFile.reset(g_key_file_new()); } else if (schemaVersion > gSchemaVersion) { // Cache file using a newer schema, use the cache in read only mode. m_readOnlyMode = true; } else { // Same schema version, we don't need to update it. return; } } g_key_file_set_integer(m_cacheFile.get(), "schema", "version", static_cast<unsigned>(gSchemaVersion)); }
char* bg_blur_pict_get_dest_path (const char* src_uri) { g_debug ("[%s] bg_blur_pict_get_dest_path: src_uri=%s", __func__, src_uri); g_return_val_if_fail (src_uri != NULL, NULL); //1. calculate original picture md5 GChecksum* checksum; checksum = g_checksum_new (G_CHECKSUM_MD5); g_checksum_update (checksum, (const guchar *) src_uri, strlen (src_uri)); guint8 digest[16]; gsize digest_len = sizeof (digest); g_checksum_get_digest (checksum, digest, &digest_len); g_assert (digest_len == 16); //2. build blurred picture path char* file; file = g_strconcat (g_checksum_get_string (checksum), ".png", NULL); g_checksum_free (checksum); char* path; path = g_build_filename (g_get_user_cache_dir (), BG_BLUR_PICT_CACHE_DIR, file, NULL); g_free (file); return path; }
GFile * xdg_cache_cache_get_temp_file (const gchar *uri, TumblerThumbnailFlavor *flavor) { const gchar *cachedir; const gchar *dirname; GTimeVal current_time = { 0, 0 }; GFile *file; gchar *filename; gchar *md5_hash; gchar *path; g_return_val_if_fail (uri != NULL && *uri != '\0', NULL); g_return_val_if_fail (TUMBLER_IS_THUMBNAIL_FLAVOR (flavor), NULL); cachedir = g_get_user_cache_dir (); dirname = tumbler_thumbnail_flavor_get_name (flavor); g_get_current_time (¤t_time); md5_hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, -1); filename = g_strdup_printf ("%s-%ld-%ld.png", md5_hash, current_time.tv_sec, current_time.tv_usec); path = g_build_filename (cachedir, "thumbnails", dirname, filename, NULL); file = g_file_new_for_path (path); g_free (path); g_free (filename); g_free (md5_hash); return file; }
char* girara_get_xdg_path(girara_xdg_path_t path) { static const char* VARS[] = { [XDG_CONFIG_DIRS] = "XDG_CONFIG_DIRS", [XDG_DATA_DIRS] = "XDG_DATA_DIRS" }; static const char* DEFAULTS[] = { [XDG_CONFIG_DIRS] = "/etc/xdg", [XDG_DATA_DIRS] = "/usr/local/share/:/usr/share" }; switch (path) { case XDG_DATA: return g_strdup(g_get_user_data_dir()); case XDG_CONFIG: return g_strdup(g_get_user_config_dir()); case XDG_CONFIG_DIRS: case XDG_DATA_DIRS: { const char* tmp = g_getenv(VARS[path]); if (tmp == NULL || !g_strcmp0(tmp, "")) { return g_strdup(DEFAULTS[path]); } return g_strdup(tmp); } case XDG_CACHE: return g_strdup(g_get_user_cache_dir()); } return NULL; }
static void pdf_load_job_from_skydrive (PdfLoadJob *job) { gchar *tmp_name; gchar *tmp_path, *pdf_path; GDateTime *updated_time; GFile *pdf_file; updated_time = zpj_skydrive_entry_get_updated_time (job->zpj_entry); job->original_file_mtime = (guint64) g_date_time_to_unix (updated_time); tmp_name = g_strdup_printf ("gnome-documents-%u.pdf", g_str_hash (zpj_skydrive_entry_get_id (job->zpj_entry))); tmp_path = g_build_filename (g_get_user_cache_dir (), "gnome-documents", NULL); job->pdf_path = pdf_path = g_build_filename (tmp_path, tmp_name, NULL); g_mkdir_with_parents (tmp_path, 0700); pdf_file = g_file_new_for_path (pdf_path); g_file_query_info_async (pdf_file, G_FILE_ATTRIBUTE_TIME_MODIFIED, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, job->cancellable, zpj_cache_query_info_ready_cb, job); g_free (tmp_name); g_free (tmp_path); g_object_unref (pdf_file); }
static void ide_runtime_real_prepare_configuration (IdeRuntime *self, IdeConfiguration *configuration) { IdeRuntimePrivate *priv = ide_runtime_get_instance_private (self); g_autofree gchar *install_path = NULL; IdeContext *context; IdeProject *project; const gchar *project_name; g_assert (IDE_IS_RUNTIME (self)); g_assert (IDE_IS_CONFIGURATION (configuration)); context = ide_object_get_context (IDE_OBJECT (self)); project = ide_context_get_project (context); project_name = ide_project_get_name (project); install_path = g_build_filename (g_get_user_cache_dir (), "gnome-builder", "install", project_name, priv->id, NULL); ide_configuration_set_prefix (configuration, install_path); }
PluginInfoCache::PluginInfoCache() : m_cacheFile(g_key_file_new()) , m_saveToFileIdle(RunLoop::main(), this, &PluginInfoCache::saveToFile) , m_readOnlyMode(false) { m_saveToFileIdle.setPriority(G_PRIORITY_DEFAULT_IDLE); GUniquePtr<char> cacheDirectory(g_build_filename(g_get_user_cache_dir(), "webkitgtk", nullptr)); if (WebCore::makeAllDirectories(cacheDirectory.get())) { // Delete old cache file. GUniquePtr<char> oldCachePath(g_build_filename(cacheDirectory.get(), "plugins", nullptr)); WebCore::deleteFile(WebCore::filenameToString(oldCachePath.get())); m_cachePath.reset(g_build_filename(cacheDirectory.get(), cacheFilenameForCurrentDisplay(), nullptr)); g_key_file_load_from_file(m_cacheFile.get(), m_cachePath.get(), G_KEY_FILE_NONE, nullptr); } if (g_key_file_has_group(m_cacheFile.get(), "schema")) { unsigned schemaVersion = static_cast<unsigned>(g_key_file_get_integer(m_cacheFile.get(), "schema", "version", nullptr)); if (schemaVersion < gSchemaVersion) { // Cache file using an old schema, create a new empty file. m_cacheFile.reset(g_key_file_new()); } else if (schemaVersion > gSchemaVersion) { // Cache file using a newer schema, use the cache in read only mode. m_readOnlyMode = true; } else { // Same schema version, we don't need to update it. return; } } g_key_file_set_integer(m_cacheFile.get(), "schema", "version", static_cast<unsigned>(gSchemaVersion)); }
/** * 接收好友头像数据. * @return 头像文件名 */ char *UdpData::RecvPalIcon() { GdkPixbuf *pixbuf; char path[MAX_PATHLEN]; char *iconfile; size_t len; int fd; /* 若无头像数据则返回null */ if ((len = strlen(buf) + 1) >= size) return NULL; /* 将头像数据刷入磁盘 */ snprintf(path, MAX_PATHLEN, "%s" ICON_PATH "/%" PRIx32, g_get_user_cache_dir(), ipv4); if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1) return NULL; xwrite(fd, buf + len, size - len); close(fd); /* 将头像pixbuf加入内建 */ iconfile = NULL; gdk_threads_enter(); if ( (pixbuf = gdk_pixbuf_new_from_file(path, NULL))) { iconfile = g_strdup_printf("%" PRIx32, ipv4); gtk_icon_theme_add_builtin_icon(iconfile, MAX_ICONSIZE, pixbuf); g_object_unref(pixbuf); } gdk_threads_leave(); return iconfile; }
static void miner_finished_cb (TrackerMinerFS *fs, gdouble seconds_elapsed, guint total_directories_found, guint total_directories_ignored, guint total_files_found, guint total_files_ignored, gpointer user_data) { /* Save locale, if it changes the variation in the desktop * file languages needs to be re-indexed. */ GError *error = NULL; gchar *locale = tracker_locale_get (TRACKER_LOCALE_LANGUAGE); gchar *locale_file = g_build_filename (g_get_user_cache_dir (), "tracker", LOCALE_FILENAME, NULL); g_message ("Saving locale used to index applications"); g_message (" Creating locale file '%s'", locale_file); if (locale == NULL) { locale = g_strdup (""); } if (!g_file_set_contents (locale_file, locale, -1, &error)) { g_message (" Could not set file contents, %s", error ? error->message : "no error given"); g_clear_error (&error); } g_free (locale); g_free (locale_file); }
/** * Retrieves the path to the cach dir. * Returned string must be freed. */ char *util_get_cache_dir(void) { char *path = g_build_filename(g_get_user_cache_dir(), PROJECT, NULL); util_create_dir_if_not_exists(path); return path; }
char * bg_pictures_source_get_cache_path (void) { return g_build_filename (g_get_user_cache_dir (), "gnome-control-center", "backgrounds", NULL); }
gchar* cedit_dirs_get_user_cache_dir(void) { const gchar* cache_dir; cache_dir = g_get_user_cache_dir(); return g_build_filename(cache_dir, "cedit", NULL); }
gchar* pluma_dirs_get_user_cache_dir(void) { const gchar* cache_dir; cache_dir = g_get_user_cache_dir(); return g_build_filename(cache_dir, "pluma", NULL); }
static void get_screenshot_async (CcBackgroundPanel *panel) { CcBackgroundPanelPrivate *priv = panel->priv; gchar *path, *tmpname; const gchar *method_name; GVariant *method_params; GtkWidget *widget; ScreenshotData *data; int primary; data = g_new0 (ScreenshotData, 1); data->panel = panel; widget = WID ("background-desktop-drawingarea"); primary = gdk_screen_get_primary_monitor (gtk_widget_get_screen (widget)); gdk_screen_get_monitor_geometry (gtk_widget_get_screen (widget), primary, &data->monitor_rect); gdk_screen_get_monitor_workarea (gtk_widget_get_screen (widget), primary, &data->workarea_rect); if (calculate_contiguous_workarea (data)) { g_debug ("Capturing only a portion of the screen"); } else { g_debug ("Capturing the whole monitor"); data->whole_monitor = TRUE; data->capture_rect = data->monitor_rect; } g_debug ("Trying to capture rectangle %dx%d (at %d,%d)", data->capture_rect.width, data->capture_rect.height, data->capture_rect.x, data->capture_rect.y); path = g_build_filename (g_get_user_cache_dir (), "gnome-control-center", NULL); g_mkdir_with_parents (path, USER_DIR_MODE); tmpname = g_strdup_printf ("scr-%d.png", g_random_int ()); g_free (panel->priv->screenshot_path); panel->priv->screenshot_path = g_build_filename (path, tmpname, NULL); g_free (path); g_free (tmpname); method_name = "ScreenshotArea"; method_params = g_variant_new ("(iiiibs)", data->capture_rect.x, data->capture_rect.y, data->capture_rect.width, data->capture_rect.height, FALSE, /* flash */ panel->priv->screenshot_path); g_dbus_connection_call (panel->priv->connection, "org.gnome.Shell.Screenshot", "/org/gnome/Shell/Screenshot", "org.gnome.Shell.Screenshot", method_name, method_params, NULL, G_DBUS_CALL_FLAGS_NONE, -1, priv->capture_cancellable, on_screenshot_finished, data); }
static gboolean bus_registry_save_cache (BusRegistry *registry) { g_assert (BUS_IS_REGISTRY (registry)); gchar *cachedir; gchar *filename; GString *output; GList *p; FILE *pf; cachedir = g_build_filename (g_get_user_cache_dir (), "ibus", "bus", NULL); filename = g_build_filename (cachedir, "registry.xml", NULL); g_mkdir_with_parents (cachedir, 0775); pf = g_fopen (filename, "w"); g_free (filename); g_free (cachedir); if (pf == NULL) { g_warning ("create registry.xml failed"); return FALSE; } output = g_string_new (""); g_string_append (output, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); g_string_append (output, "<!-- \n" " This file was generated by ibus-daemon. Please don't modify it.\n" " -->\n"); g_string_append (output, "<ibus-registry>\n"); if (registry->observed_paths) { g_string_append_indent (output, 1); g_string_append (output, "<observed-paths>\n"); for (p = registry->observed_paths; p != NULL; p = p->next) { ibus_observed_path_output ((IBusObservedPath *)p->data, output, 2); } g_string_append_indent (output, 1); g_string_append (output, "</observed-paths>\n"); } if (registry->components) { g_string_append_indent (output, 1); g_string_append (output, "<components>\n"); for (p = registry->components; p != NULL; p = p->next) { ibus_component_output ((IBusComponent *)p->data, output, 2); } g_string_append_indent (output, 1); g_string_append (output, "</components>\n"); } g_string_append (output, "</ibus-registry>\n"); fwrite (output->str, output->len, 1, pf); g_string_free (output, TRUE); fclose (pf); return TRUE; }
static gchar * photos_facebook_item_download (PhotosBaseItem *item, GCancellable *cancellable, GError **error) { GFBGraphPhoto *photo; const GFBGraphPhotoImage *higher_image; const gchar *identifier; gchar *local_dir, *filename, *local_filename; GFile *local_file, *remote_file; photo = photos_facebook_get_gfbgraph_photo (item, cancellable, error); if (photo == NULL) { g_error ("Can't get the photo from the Facebook Graph\n"); } else { higher_image = gfbgraph_photo_get_image_hires (photo); if (higher_image == NULL) { g_error ("Cant' get the higher photo size from Facebook.\n"); } else { remote_file = g_file_new_for_uri (higher_image->source); /* Local path */ local_dir = g_build_filename (g_get_user_cache_dir (), PACKAGE_TARNAME, "facebook", NULL); g_mkdir_with_parents (local_dir, 0700); /* Local filename */ identifier = photos_base_item_get_identifier (item) + strlen("facebook:photos:"); filename = g_strdup_printf ("%s.jpeg", identifier); local_filename = g_build_filename (local_dir, filename, NULL); local_file = g_file_new_for_path (local_filename); g_debug ("Downloading %s from Facebook to %s", higher_image->source, local_filename); if (!g_file_copy (remote_file, local_file, G_FILE_COPY_ALL_METADATA | G_FILE_COPY_OVERWRITE, cancellable, NULL, NULL, error)) g_warning ("Failed downloading %s from Facebook to %s\n", higher_image->source, local_filename); g_free (filename); g_free (local_dir); g_clear_object (&local_file); g_clear_object (&remote_file); } g_clear_object (&photo); } return local_filename; }
/* * compute cache file's absolute name */ static gchar * compute_data_file_name (GdaQuarkList *params, gboolean is_cache, const gchar *data_type) { /* real cache file name */ GString *string; gchar *cfile, *evalue; const gchar *base_dn; const gchar *host; const gchar *require_ssl; const gchar *port; gint rport; gboolean use_ssl; base_dn = gda_quark_list_find (params, "DB_NAME"); host = gda_quark_list_find (params, "HOST"); if (!host) host = "127.0.0.1"; port = gda_quark_list_find (params, "PORT"); require_ssl = gda_quark_list_find (params, "USE_SSL"); use_ssl = (require_ssl && ((*require_ssl == 't') || (*require_ssl == 'T'))) ? TRUE : FALSE; if (port && *port) rport = atoi (port); else { if (use_ssl) rport = LDAPS_PORT; else rport = LDAP_PORT; } string = g_string_new (""); evalue = gda_rfc1738_encode (host); g_string_append_printf (string, ",=%s", evalue); g_free (evalue); g_string_append_printf (string, ";PORT=%d", rport); if (base_dn) { evalue = gda_rfc1738_encode (base_dn); g_string_append_printf (string, ";BASE_DN,=%s", evalue); g_free (evalue); } evalue = g_compute_checksum_for_string (G_CHECKSUM_SHA1, string->str, -1); g_string_free (string, TRUE); if (is_cache) cfile = g_strdup_printf ("%s_%s", evalue, data_type); else cfile = g_strdup_printf ("ldap-%s.%s", evalue, data_type); g_free (evalue); gchar *fname; if (is_cache) fname = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (), "libgda", "ldap", cfile, NULL); else fname = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (), "libgda", cfile, NULL); g_free (cfile); return fname; }
/* {{{ proto string Glib::userCacheDir() Returns a base directory in which to store non-essential, cached data specific to particular user. */ PHP_METHOD(Glib, userCacheDir) { if (zend_parse_parameters_none() == FAILURE) { return; } const char *name = g_get_user_cache_dir(); RETURN_STRING(name, 1); }
static void rm_swap_table_create_cachedir(GError **error) { char *path = g_build_filename(g_get_user_cache_dir(), "rmlint", NULL); if(g_mkdir_with_parents(path, 0775) == -1) { SET_ERROR("cannot create cache dir %s: %s", path, g_strerror(errno)); } g_free(path); }
static gboolean detect_locale_changed (TrackerMiner *miner) { gchar *locale_file; gchar *previous_locale = NULL; gchar *current_locale; gboolean changed; locale_file = g_build_filename (g_get_user_cache_dir (), "tracker", LOCALE_FILENAME, NULL); if (G_LIKELY (g_file_test (locale_file, G_FILE_TEST_EXISTS))) { gchar *contents; /* Check locale is correct */ if (G_LIKELY (g_file_get_contents (locale_file, &contents, NULL, NULL))) { if (contents && contents[0] == '\0') { g_critical (" Empty locale file found at '%s'", locale_file); g_free (contents); } else { /* Re-use contents */ previous_locale = contents; } } else { g_critical (" Could not get content of file '%s'", locale_file); } } else { g_message (" Could not find locale file:'%s'", locale_file); } g_free (locale_file); current_locale = tracker_locale_get (TRACKER_LOCALE_LANGUAGE); /* Note that having both to NULL is actually valid, they would default * to the unicode collation without locale-specific stuff. */ if (g_strcmp0 (previous_locale, current_locale) != 0) { g_message ("Locale change detected from '%s' to '%s'...", previous_locale, current_locale); changed = TRUE; } else { g_message ("Current and previous locales match: '%s'", previous_locale); changed = FALSE; } g_free (current_locale); g_free (previous_locale); if (changed) { g_message ("Locale change detected, so resetting miner to " "remove all previously created items..."); miner_applications_reset (miner); } return changed; }
static gboolean bus_registry_load_cache (BusRegistry *registry) { g_assert (BUS_IS_REGISTRY (registry)); gchar *filename; XMLNode *node; GList *p; filename = g_build_filename (g_get_user_cache_dir (), "ibus", "bus", "registry.xml", NULL); node = ibus_xml_parse_file (filename); g_free (filename); if (node == NULL) { return FALSE; } if (g_strcmp0 (node->name, "ibus-registry") != 0) { ibus_xml_free (node); return FALSE; } for (p = node->sub_nodes; p != NULL; p = p->next) { XMLNode *sub_node = (XMLNode *) p->data; if (g_strcmp0 (sub_node->name, "observed-paths") == 0) { GList *pp; for (pp = sub_node->sub_nodes; pp != NULL; pp = pp->next) { IBusObservedPath *path; path = ibus_observed_path_new_from_xml_node (pp->data, FALSE); if (path) { g_object_ref_sink (path); registry->observed_paths = g_list_append (registry->observed_paths, path); } } continue; } if (g_strcmp0 (sub_node->name, "components") == 0) { GList *pp; for (pp = sub_node->sub_nodes; pp != NULL; pp = pp->next) { IBusComponent *component; component = ibus_component_new_from_xml_node (pp->data); if (component) { g_object_ref_sink (component); registry->components = g_list_append (registry->components, component); } } continue; } g_warning ("Unknown element <%s>", sub_node->name); } ibus_xml_free (node); return TRUE; }
static gboolean init(LXTermWindow* lxtermwin, gint argc, gchar** argv) { /* Normally, LXTerminal uses one process to control all of its windows. * The first process to start will create a Unix domain socket in * g_get_user_runtime_dir(). It will then bind and listen on this socket. * The subsequent processes will connect to the controller that owns the * Unix domain socket. They will pass their command line over the socket * and exit. * * If for any reason both the connect and bind fail, we will fall back to * having that process be standalone; it will not be either the controller * or a user of the controller. * * This function returns TRUE if this process should keep running and FALSE * if it should exit. */ /* Formulate the path for the Unix domain socket. */ #if GLIB_CHECK_VERSION (2, 28, 0) gchar * socket_path = g_strdup_printf("%s/.lxterminal-socket-%s", g_get_user_runtime_dir(), gdk_display_get_name(gdk_display_get_default())); #else gchar * socket_path = g_strdup_printf("%s/.lxterminal-socket-%s", g_get_user_cache_dir(), gdk_display_get_name(gdk_display_get_default())); #endif /* Create socket. */ int fd = socket(PF_UNIX, SOCK_STREAM, 0); if (fd < 0) { g_warning("Socket create failed: %s\n", g_strerror(errno)); goto err_socket; } /* Initialize socket address for Unix domain socket. */ struct sockaddr_un sock_addr; memset(&sock_addr, 0, sizeof(sock_addr)); sock_addr.sun_family = AF_UNIX; snprintf(sock_addr.sun_path, sizeof(sock_addr.sun_path), "%s", socket_path); /* Try to connect to an existing LXTerminal process. */ if (connect(fd, (struct sockaddr *) &sock_addr, sizeof(sock_addr)) == 0) { g_free(socket_path); send_msg_to_controller(fd, argc, argv); return FALSE; } unlink(socket_path); g_free(socket_path); start_controller(&sock_addr, lxtermwin, fd); return TRUE; err_socket: g_free(socket_path); return TRUE; }
static void init_directories(void) { /* create luakit directory */ globalconf.cache_dir = g_build_filename(g_get_user_cache_dir(), "luakit", globalconf.profile, NULL); globalconf.config_dir = g_build_filename(g_get_user_config_dir(), "luakit", globalconf.profile, NULL); globalconf.data_dir = g_build_filename(g_get_user_data_dir(), "luakit", globalconf.profile, NULL); g_mkdir_with_parents(globalconf.cache_dir, 0771); g_mkdir_with_parents(globalconf.config_dir, 0771); g_mkdir_with_parents(globalconf.data_dir, 0771); }
void propono_cache_prefs_init (void) { keyfile = g_key_file_new (); filename = g_build_filename (g_get_user_cache_dir (), "propono", "propono-prefs-cache.ini", NULL); g_key_file_load_from_file (keyfile, filename, 0, NULL); }