static char * try_worktree (const char *worktree) { char *tmp; unsigned int cnt; /* There is a repo name conflict, so we try to add a postfix */ cnt = 1; while (1) { tmp = g_strdup_printf("%s-%d", worktree, cnt++); if (g_access(tmp, F_OK) < 0) { return tmp; } if (cnt == -1U) { /* we have tried too much times, so give up */ g_free(tmp); return NULL; } g_free(tmp); } /* XXX: never reach here */ }
static void load_ll_tz_dir ( const gchar *dir ) { gchar *lltz = g_build_filename ( dir, "latlontz.txt", NULL ); if ( g_access(lltz, R_OK) == 0 ) { gchar buffer[4096]; long line_num = 0; FILE *ff = g_fopen ( lltz, "r" ); while ( fgets ( buffer, 4096, ff ) ) { line_num++; gchar **components = g_strsplit (buffer, " ", 3); guint nn = g_strv_length ( components ); if ( nn == 3 ) { double pt[2] = { g_ascii_strtod (components[0], NULL), g_ascii_strtod (components[1], NULL) }; gchar *timezone = g_strchomp ( components[2] ); if ( kd_insert ( kd, pt, timezone ) ) g_critical ( "Insertion problem of %s for line %ld of latlontz.txt", timezone, line_num ); // NB Don't free timezone as it's part of the kdtree data now g_free ( components[0] ); g_free ( components[1] ); } else { g_warning ( "Line %ld of latlontz.txt does not have 3 parts", line_num ); } g_free ( components ); } fclose ( ff ); } g_free ( lltz ); }
static char * make_worktree_for_download (SeafCloneManager *mgr, const char *wt_tmp, GError **error) { char *worktree; if (g_access (wt_tmp, F_OK) == 0) { worktree = try_worktree (wt_tmp); } else { worktree = g_strdup(wt_tmp); } if (!check_worktree_path (mgr, worktree, error)) { g_free (worktree); return NULL; } if (g_mkdir (worktree, 0777) < 0) { seaf_warning ("[clone mgr] Failed to create dir %s.\n", worktree); g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL, "Failed to create worktree"); g_free (worktree); return NULL; } return worktree; }
static gboolean ensure_dot_mate_exists (void) { gboolean retval = TRUE; gboolean create_dirs; gchar *dirname; /* If the user does not have a writable HOME directory, then avoid creating the directory. */ create_dirs = (g_access (g_get_home_dir(), W_OK) == 0); if (create_dirs != TRUE) return TRUE; dirname = g_build_filename (g_get_home_dir (), ".mate2", NULL); if (!g_file_test (dirname, G_FILE_TEST_EXISTS)) { if (g_mkdir (dirname, S_IRWXU) != 0) { g_warning ("Unable to create ~/.mate2 directory: %s", g_strerror (errno)); retval = FALSE; } } else if (!g_file_test (dirname, G_FILE_TEST_IS_DIR)) { g_warning ("Error: ~/.mate2 must be a directory."); retval = FALSE; } g_free (dirname); return retval; }
static int g_bde_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp) { struct g_consumer *cp; struct g_provider *pp; struct g_bde_softc *sc; g_trace(G_T_TOPOLOGY, "g_bde_destroy_geom(%s, %s)", mp->name, gp->name); g_topology_assert(); /* * Orderly detachment. */ KASSERT(gp != NULL, ("NULL geom")); pp = LIST_FIRST(&gp->provider); KASSERT(pp != NULL, ("NULL provider")); if (pp->acr > 0 || pp->acw > 0 || pp->ace > 0) return (EBUSY); sc = gp->softc; cp = LIST_FIRST(&gp->consumer); KASSERT(cp != NULL, ("NULL consumer")); sc->dead = 1; wakeup(sc); g_access(cp, -1, -1, -1); g_detach(cp); g_destroy_consumer(cp); while (sc->dead != 2 && !LIST_EMPTY(&pp->consumers)) tsleep(sc, PRIBIO, "g_bdedie", hz); mtx_destroy(&sc->worklist_mutex); bzero(&sc->key, sizeof sc->key); g_free(sc); g_wither_geom(gp, ENXIO); return (0); }
static gboolean html_open_uri_cb(ChmseeIhtml* html, const gchar *uri, ChmSee *self) { g_debug("enter html_open_uri_cb with uri = %s", uri); static const char* prefix = "file://"; static int prefix_len = 7; if(g_str_has_prefix(uri, prefix)) { /* FIXME: can't disable the DND function of GtkMozEmbed */ if(g_str_has_suffix(uri, ".chm") || g_str_has_suffix(uri, ".CHM")) { chmsee_open_uri(self, uri); } if(g_access(uri+prefix_len, R_OK) < 0) { g_debug("%s:%d:html_open_uri_cb:%s does not exist", __FILE__, __LINE__, uri+prefix_len); gchar* newfname = correct_filename(uri+prefix_len); if(newfname) { g_message(_("URI redirect: \"%s\" -> \"%s\""), uri, newfname); chmsee_ihtml_open_uri(html, newfname); g_free(newfname); return TRUE; } if(selfp->state == CHMSEE_STATE_LOADING) { return TRUE; } } } if ((html == get_active_html(self)) && selfp->has_toc) booktree_select_uri(BOOKTREE (selfp->booktree), uri); return FALSE; }
static void start_clone_v2 (CloneTask *task) { GError *error = NULL; if (g_access (task->worktree, F_OK) != 0 && g_mkdir_with_parents (task->worktree, 0777) < 0) { seaf_warning ("[clone mgr] Failed to create worktree %s.\n", task->worktree); transition_to_error (task, CLONE_ERROR_FETCH); return; } SeafRepo *repo = seaf_repo_manager_get_repo (seaf->repo_mgr, task->repo_id); if (repo != NULL) { seaf_repo_manager_set_repo_token (seaf->repo_mgr, repo, task->token); seaf_repo_manager_set_repo_email (seaf->repo_mgr, repo, task->email); seaf_repo_manager_set_repo_relay_info (seaf->repo_mgr, repo->id, task->peer_addr, task->peer_port); if (task->server_url) { seaf_repo_manager_set_repo_property (seaf->repo_mgr, repo->id, REPO_PROP_SERVER_URL, task->server_url); } mark_clone_done_v2 (repo, task); return; } if (add_transfer_task (task, &error) == 0) transition_state (task, CLONE_STATE_FETCH); else transition_to_error (task, CLONE_ERROR_FETCH); }
static char * get_storage_path (CamelSession *session, CamelService *service, CamelException *ex) { char *path, *p; p = camel_service_get_path (service); path = g_strdup_printf ("%s/%s", session->storage_path, p); g_free (p); #ifdef G_OS_WIN32 if (g_access (path, F_OK) == 0) #else if (access (path, F_OK) == 0) #endif return path; if (g_mkdir_with_parents (path, S_IRWXU) == -1) { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Could not create directory %s:\n%s"), path, g_strerror (errno)); g_free (path); return NULL; } return path; }
static CamelFolder * groupwise_get_folder_from_disk (CamelStore *store, const gchar *folder_name, guint32 flags, GCancellable *cancellable, GError **error) { CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (store); CamelGroupwiseStorePrivate *priv = gw_store->priv; CamelFolder *folder; gchar *folder_dir, *storage_path; storage_path = g_strdup_printf("%s/folders", priv->storage_path); folder_dir = e_path_to_physical (storage_path, folder_name); g_free (storage_path); if (!folder_dir || g_access (folder_dir, F_OK) != 0) { g_free (folder_dir); g_set_error ( error, CAMEL_STORE_ERROR, CAMEL_STORE_ERROR_NO_FOLDER, _("No such folder %s"), folder_name); return NULL; } folder = camel_gw_folder_new (store, folder_name, folder_dir, cancellable, error); g_free (folder_dir); return folder; }
/* Note the only way to reliably test readability on Windows is to actually try to open the file. Here we are basically checking for existence. */ gboolean file_is_readable (const gchar *fileName) { if (GLIB_CHECK_VERSION(2,8,0)) return(!g_access(fileName, R_OK)); return !access(fileName, R_OK); }
static void setup() { client = ccnet_client_new (); if ( ccnet_client_load_confdir(client, CCNET_DIR) < 0 ) { fprintf (stderr, "Read config dir error\n"); exit(1); } event_init (); if (g_access (TEST_DIR "worktree", F_OK) != 0 && g_mkdir (TEST_DIR "worktree", 0777) < 0) { fprintf (stderr, "Failed to create worktree.\n"); exit (1); } seaf = seafile_session_new (SEAF_DIR, WORKTREE_DIR, client); if (!seaf) { fprintf (stderr, "Failed to create seafile session.\n"); exit (1); } seafile_session_prepare (seaf); }
static gboolean lmplayer_lyric_widget_da_add_file(LmplayerLyricWidget *lyric, const gchar *file) { g_return_val_if_fail(LMPLAYER_IS_LYRIC_WIDGET_DA(lyric), FALSE); g_return_val_if_fail(file != NULL, FALSE); LmplayerLyricWidgetDaPrivate *priv = LMPLAYER_LYRIC_WIDGET_DA(lyric)->priv; if(g_access(file, R_OK) != 0) return FALSE; if(priv->lines != NULL) { g_list_free(priv->lines); priv->lines = NULL; priv->da_height = 0; } priv->loaded = parse_lyric_file_without_check(LMPLAYER_LYRIC_WIDGET_DA(lyric), file); if(priv->loaded) { gtk_layout_move(GTK_LAYOUT(lyric), priv->alignment, 0, 0); gdk_window_invalidate_rect(priv->da->window, NULL, FALSE); } priv->changed = TRUE; priv->current_second = -1; update_pixmap(LMPLAYER_LYRIC_WIDGET_DA(lyric)); return priv->loaded; }
static Suite * profile_suite (void) { Suite *s = suite_create ("profile support library"); TCase *tc_chain = tcase_create ("general"); gboolean can_write; gchar *gst_dir; /* cehck if we can create profiles */ gst_dir = g_build_filename (g_get_home_dir (), ".gstreamer-0.10", NULL); can_write = (g_access (gst_dir, R_OK | W_OK | X_OK) == 0); g_free (gst_dir); suite_add_tcase (s, tc_chain); tcase_add_test (tc_chain, test_profile_creation); tcase_add_test (tc_chain, test_profile_input_caps); tcase_add_test (tc_chain, test_target_naming); tcase_add_test (tc_chain, test_target_profile); if (can_write) { tcase_add_test (tc_chain, test_loading_profile); tcase_add_test (tc_chain, test_saving_profile); tcase_add_test (tc_chain, test_target_list); } tcase_add_unchecked_fixture (tc_chain, test_setup, test_teardown); return s; }
int32 WriteFile(ExtensionString filename, std::string contents, ExtensionString encoding) { const char *filenameStr = filename.c_str(); int error = NO_ERROR; GError *gerror = NULL; if (encoding != "utf8") { return ERR_UNSUPPORTED_ENCODING; } else if (g_file_test(filenameStr, G_FILE_TEST_EXISTS) && g_access(filenameStr, W_OK) == -1) { return ERR_CANT_WRITE; } FILE* file = fopen(filenameStr, "w"); if (file) { size_t size = fwrite(contents.c_str(), sizeof(gchar), contents.length(), file); if (size != contents.length()) { error = ERR_CANT_WRITE; } fclose(file); } else { return ConvertLinuxErrorCode(errno); } return error; }
static Suite * gst_preset_suite (void) { Suite *s = suite_create ("GstPreset"); TCase *tc = tcase_create ("preset"); gchar *gst_dir; gboolean can_write = FALSE; /* cehck if we can create presets */ gst_dir = g_build_filename (g_get_home_dir (), ".gstreamer-" GST_MAJORMINOR, NULL); can_write = (g_access (gst_dir, R_OK | W_OK | X_OK) == 0); g_free (gst_dir); suite_add_tcase (s, tc); tcase_add_test (tc, test_check); tcase_add_test (tc, test_load); if (can_write) { tcase_add_test (tc, test_add); tcase_add_test (tc, test_del); tcase_add_test (tc, test_two_instances); } tcase_add_unchecked_fixture (tc, test_setup, test_teardown); return s; }
static gboolean mkdg_config_file_key_file_open(MkdgConfigFile *configFile, MkdgError **error){ MkdgError * cfgErr=NULL, *cfgErr_prep=NULL; if (g_access(configFile->path,R_OK)==0){ GKeyFile *keyFile=g_key_file_new(); configFile->fileObj= (gpointer) keyFile; g_key_file_load_from_file(keyFile, configFile->path, G_KEY_FILE_NONE, &cfgErr_prep); if (cfgErr_prep){ if (cfgErr->code==G_KEY_FILE_ERROR_PARSE){ /* Possibly empty file */ g_warning("Error parse on file %s, but it can also mean an empty file.", configFile->path); mkdg_error_handle(cfgErr_prep,error); }else{ cfgErr=convert_error_code(cfgErr_prep, configFile->path, "config_file_key_file_open(): g_key_file_load_from_file"); mkdg_error_handle(cfgErr,error); if (keyFile){ g_key_file_free(keyFile); } return FALSE; } }else{ /* No error */ configFile->flags |= MKDG_CONFIG_FILE_FLAG_HAS_CONTENT; } return TRUE; } cfgErr=mkdg_error_new(MKDG_ERROR_CONFIG_CANT_READ, "File %s cannot be read!", configFile->path); mkdg_error_handle(cfgErr,error); return FALSE; }
gchar* prefs_get_config_filename (gchar *config_filename, GUI *appGUI) { static gchar dirname[PATH_MAX], filename[PATH_MAX]; struct stat cfg; if (appGUI->config_path == NULL) { #if defined(CONFIG_PATH) && defined(CONFIG_DIR) g_snprintf(dirname, PATH_MAX, "%s%c%s", CONFIG_PATH, G_DIR_SEPARATOR, CONFIG_DIR); #elif defined(CONFIG_DIR) g_snprintf(dirname, PATH_MAX, "%s%c%s", g_get_home_dir(), G_DIR_SEPARATOR, CONFIG_DIR); #elif defined(CONFIG_PATH) g_snprintf(dirname, PATH_MAX, "%s%c%s", CONFIG_PATH, G_DIR_SEPARATOR, CONFIG_DIRNAME); #else g_snprintf(dirname, PATH_MAX, "%s%c%s", g_get_home_dir(), G_DIR_SEPARATOR, CONFIG_DIRNAME); #endif } else { g_strlcpy (dirname, appGUI->config_path, PATH_MAX); } if(g_stat (dirname, &cfg) < 0) g_mkdir (dirname, S_IRUSR | S_IWUSR | S_IXUSR); if (g_access (dirname, R_OK | W_OK) == -1) { return NULL; } g_snprintf(filename, PATH_MAX, "%s%c%s", dirname, G_DIR_SEPARATOR, config_filename); return filename; }
void _gs_profile_log (const char *func, const char *note, const char *format, ...) { va_list args; char *str; char *formatted; if (format == NULL) { formatted = g_strdup (""); } else { va_start (args, format); formatted = g_strdup_vprintf (format, args); va_end (args); } if (func != NULL) { str = g_strdup_printf ("MARK: %s %s: %s %s", g_get_prgname(), func, note ? note : "", formatted); } else { str = g_strdup_printf ("MARK: %s: %s %s", g_get_prgname(), note ? note : "", formatted); } g_free (formatted); g_access (str, F_OK); g_free (str); }
static void groupwise_forget_folder (CamelGroupwiseStore *gw_store, const gchar *folder_name, GError **error) { CamelGroupwiseStorePrivate *priv = gw_store->priv; gchar *state_file; gchar *folder_dir, *storage_path; CamelFolderInfo *fi; storage_path = g_strdup_printf ("%s/folders", priv->storage_path); folder_dir = e_path_to_physical (storage_path,folder_name); if (g_access (folder_dir, F_OK) != 0) { g_free (folder_dir); return; } state_file = g_strdup_printf ("%s/cmeta", folder_dir); g_unlink (state_file); g_free (state_file); g_rmdir (folder_dir); g_free (folder_dir); camel_store_summary_remove_path ( (CamelStoreSummary *)gw_store->summary, folder_name); camel_store_summary_save ( (CamelStoreSummary *)gw_store->summary); fi = groupwise_build_folder_info (gw_store, NULL, folder_name); camel_store_folder_deleted (CAMEL_STORE (gw_store), fi); camel_folder_info_free (fi); }
/** * Test whether there's a settings lock due to pending * backup/restore or device clear/factory reset operation * * @return TRUE if the settings lock file is in place, * FALSE if the settings lock file is not in place */ gboolean mce_are_settings_locked(void) { gboolean status = (g_access(MCE_SETTINGS_LOCK_FILE_PATH, F_OK) == 0); errno = 0; return status; }
static int access_wrapper (char const *filename, int what) { #ifdef HAVE_G_ACCESS return g_access (filename, what); #else return access (filename, what); #endif }
/* When the selected file is changed, check whether the user has write accesss. */ static void file_changed (GtkFileChooser *file, Widgets *w) { gchar *fn = gtk_file_chooser_get_filename (file); gint mode = g_access (fn, W_OK); gtk_widget_set_sensitive (w->rnm, !mode); gtk_widget_set_sensitive (w->name, !mode); }
static gboolean rc_plugin_tag_vorbis_change(const gchar *src_path, const gchar *target_path, const GstTagList *tag_list) { GstElement *tag_filesrc = NULL; GstElement *tag_filesink = NULL; GstElement *tag_demux = NULL; GstElement *tag_mux = NULL; GstElement *tagger = NULL; GstBus *bus = NULL; if(src_path==NULL) return FALSE; if(target_path==NULL) return FALSE; if(tag_list==NULL) return FALSE; if(g_access(src_path, W_OK)!=0) return FALSE; tagger = gst_element_factory_make("vorbistag", "vorbis-tagger"); tag_demux = gst_element_factory_make("oggdemux", "ogg-demux"); tag_mux = gst_element_factory_make("oggmux", "ogg-mux"); if(tagger==NULL || tag_demux==NULL || tag_mux==NULL) goto error_out; tag_filesrc = gst_element_factory_make("filesrc", "tag-filesrc"); if(tag_filesrc==NULL) goto error_out; tag_filesink = gst_element_factory_make("filesink", "tag-filesink"); if(tag_filesink==NULL) goto error_out; g_object_set(G_OBJECT(tag_filesrc), "location", src_path, NULL); g_object_set(G_OBJECT(tag_filesink), "location", target_path, NULL); tagger_pipeline = gst_pipeline_new("tagger-pipeline"); gst_tag_setter_merge_tags(GST_TAG_SETTER(tagger), tag_list, GST_TAG_MERGE_REPLACE); gst_bin_add_many(GST_BIN(tagger_pipeline), tag_filesrc, tag_demux, tagger, tag_mux, tag_filesink, NULL); g_signal_connect(tag_demux, "pad-added", G_CALLBACK(rc_plugin_tag_writer_pad_added_cb), tagger); if(!gst_element_link(tag_filesrc, tag_demux)) goto error_out; if(!gst_element_link_many(tagger, tag_mux, tag_filesink, NULL)) goto error_out; bus = gst_pipeline_get_bus(GST_PIPELINE(tagger_pipeline)); gst_bus_add_watch(bus, (GstBusFunc)rc_plugin_tag_writer_bus_cb, NULL); gst_object_unref(bus); gst_element_set_state(tagger_pipeline, GST_STATE_NULL); gst_element_set_state(tagger_pipeline, GST_STATE_READY); if(gst_element_set_state(tagger_pipeline, GST_STATE_PLAYING) ==GST_STATE_CHANGE_FAILURE) goto error_out; return TRUE; error_out: if(tagger!=NULL) gst_object_unref(tagger); if(tag_demux!=NULL) gst_object_unref(tag_demux); if(tag_mux!=NULL) gst_object_unref(tag_mux); if(tag_filesrc!=NULL) gst_object_unref(tag_filesrc); if(tag_filesink!=NULL) gst_object_unref(tag_filesink); if(tagger_pipeline!=NULL) gst_object_unref(tagger_pipeline); tagger_pipeline = NULL; return FALSE; }
static void log_write (session *sess, char *text, time_t ts) { char *temp; char *stamp; char *file; int len; if (sess->text_logging == SET_DEFAULT) { if (!prefs.hex_irc_logging) return; } else { if (sess->text_logging != SET_ON) return; } if (sess->logfd == -1) log_open (sess); /* change to a different log file? */ file = log_create_pathname (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE)); if (file) { if (g_access (file, F_OK) != 0) { close (sess->logfd); sess->logfd = log_open_file (sess->server->servername, sess->channel, server_get_network (sess->server, FALSE)); } g_free (file); } if (prefs.hex_stamp_log) { if (!ts) ts = time(0); len = get_stamp_str (prefs.hex_stamp_log_format, ts, &stamp); if (len) { write (sess->logfd, stamp, len); g_free (stamp); } } temp = strip_color (text, -1, STRIP_ALL); len = strlen (temp); write (sess->logfd, temp, len); /* lots of scripts/plugins print without a \n at the end */ if (temp[len - 1] != '\n') write (sess->logfd, "\n", 1); /* emulate what xtext would display */ g_free (temp); }
static int g_mbr_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td) { struct g_geom *gp; struct g_mbr_softc *ms; struct g_slicer *gsp; struct g_consumer *cp; int error, opened; gp = pp->geom; gsp = gp->softc; ms = gsp->softc; opened = 0; error = 0; switch(cmd) { case DIOCSMBR: { if (!(fflag & FWRITE)) return (EPERM); DROP_GIANT(); g_topology_lock(); cp = LIST_FIRST(&gp->consumer); if (cp->acw == 0) { error = g_access(cp, 0, 1, 0); if (error == 0) opened = 1; } if (!error) error = g_mbr_modify(gp, ms, data, 512); if (!error) error = g_write_data(cp, 0, data, 512); if (opened) g_access(cp, 0, -1 , 0); g_topology_unlock(); PICKUP_GIANT(); return(error); } default: return (ENOIOCTL); } }
static storage_status_t xml_save( irc_t *irc, int overwrite ) { storage_status_t ret = STORAGE_OK; char path[512], *path2 = NULL, *xml = NULL; struct xt_node *tree = NULL; size_t len; int fd; path2 = g_strdup( irc->user->nick ); nick_lc( NULL, path2 ); g_snprintf( path, sizeof( path ) - 20, "%s%s%s", global.conf->configdir, path2, ".xml" ); g_free( path2 ); if( !overwrite && g_access( path, F_OK ) == 0 ) return STORAGE_ALREADY_EXISTS; strcat( path, ".XXXXXX" ); if( ( fd = mkstemp( path ) ) < 0 ) { irc_rootmsg( irc, "Error while opening configuration file." ); return STORAGE_OTHER_ERROR; } tree = xml_generate( irc ); xml = xt_to_string_i( tree ); len = strlen( xml ); if( write( fd, xml, len ) != len || fsync( fd ) != 0 || /* #559 */ close( fd ) != 0 ) goto error; path2 = g_strndup( path, strlen( path ) - 7 ); if( rename( path, path2 ) != 0 ) { g_free( path2 ); goto error; } g_free( path2 ); goto finish; error: irc_rootmsg( irc, "Write error. Disk full?" ); ret = STORAGE_OTHER_ERROR; finish: close( fd ); unlink( path ); g_free( xml ); xt_free_node( tree ); return ret; }
static int initCookieManager(WebKitSettings *webkitSettings) { if(!webkitSettings) return 0; // Enable cooki manager to store cookie message.--- by Jiayu WebKitCookieManager* cookiemanager = webkit_web_context_get_cookie_manager(webkit_web_context_get_default()); int error = 0; gchar* home = getenv("HOME"); gchar cookieDatabasePath[2048]; g_sprintf(cookieDatabasePath, "%s/.cookie", home); if(!g_file_test(cookieDatabasePath, G_FILE_TEST_IS_DIR) || !g_access(cookieDatabasePath, /*S_IWUSR|S_IRUSR*/0755)){ error = g_mkdir_with_parents(cookieDatabasePath, /*S_IWUSR|S_IRUSR*/ 0755); } if(!error){ gchar cookieDatabase[2048]; g_sprintf(cookieDatabase, "%s/cookie_database", cookieDatabasePath); g_printf("cookiedatabase path is %s\n", cookieDatabase); webkit_cookie_manager_set_persistent_storage(cookiemanager, cookieDatabase, WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE); }else{ g_printerr("LOG-> Init: Failed to init cookie database\n"); return 0; } //g_mkdir_with_parents(cookieDatabaePath, ); //webkit_cookie_manager_set_persistent_storage(cookiemanager, "cookies_database", WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE); WebKitCookieAcceptPolicy cookiePolicy = WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS; int cookieSetting; error = 0; g_object_get(webkitSettings, key[PROP_COOKIE_SETTING], &cookieSetting, NULL); switch(cookieSetting){ case 0: cookiePolicy = WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS; break; case 1: cookiePolicy = WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY; break; case 2: cookiePolicy = WEBKIT_COOKIE_POLICY_ACCEPT_NEVER; break; default: error = 1; g_printerr("LOG-> Settings: Failed to get the correct cookie setting policy\n"); break; } if(error) return 0; else{ webkit_cookie_manager_set_accept_policy(cookiemanager,cookiePolicy); return 1; } }
static void start_checkout (SeafRepo *repo, CloneTask *task) { if (repo->encrypted && task->passwd != NULL) { /* keep this password check to be compatible with old servers. */ if (repo->enc_version >= 1 && seaf_repo_verify_passwd (repo->id, task->passwd, repo->magic) < 0) { seaf_warning ("[Clone mgr] incorrect password.\n"); transition_to_error (task, CLONE_ERROR_PASSWD); return; } if (seaf_repo_manager_set_repo_passwd (seaf->repo_mgr, repo, task->passwd) < 0) { seaf_warning ("[Clone mgr] failed to set passwd for %s.\n", repo->id); transition_to_error (task, CLONE_ERROR_INTERNAL); return; } } else if (repo->encrypted) { seaf_warning ("[Clone mgr] Password is empty for encrypted repo %s.\n", repo->id); transition_to_error (task, CLONE_ERROR_PASSWD); return; } if (g_access (task->worktree, F_OK) != 0 && g_mkdir_with_parents (task->worktree, 0777) < 0) { seaf_warning ("[clone mgr] Failed to create worktree %s.\n", task->worktree); transition_to_error (task, CLONE_ERROR_CHECKOUT); return; } if (!is_non_empty_directory (task->worktree)) { transition_state (task, CLONE_STATE_CHECKOUT); seaf_repo_manager_add_checkout_task (seaf->repo_mgr, repo, task->worktree, on_checkout_done, task->manager); } else { MergeAux *aux = g_new0 (MergeAux, 1); aux->task = task; aux->repo = repo; transition_state (task, CLONE_STATE_MERGE); ccnet_job_manager_schedule_job (seaf->job_mgr, merge_job, merge_job_done, aux); } }
/** * Init function for the modetransition component * * @return TRUE on success, FALSE on failure */ gboolean mce_mode_init(void) { gboolean status = FALSE; /* Append triggers/filters to datapipes */ mce_mode_datapipe_init(); /* If the bootup file exists, mce has crashed / restarted; * since it exists in /var/run it will be removed when we reboot. * * If the file doesn't exist, create it to ensure that * restarting mce doesn't get mce stuck in the transition submode */ if (g_access(MCE_BOOTUP_FILENAME, F_OK) == -1) { if (errno == ENOENT) { mce_log(LL_DEBUG, "Bootup mode enabled"); mce_add_submode_int32(MCE_SUBMODE_TRANSITION); errno = 0; mce_write_string_to_file(MCE_BOOTUP_FILENAME, ENABLED_STRING); if (g_access(MALF_FILENAME, F_OK) == 0) { mce_add_submode_int32(MCE_SUBMODE_MALF); mce_log(LL_DEBUG, "Malf mode enabled"); if (g_access(MCE_MALF_FILENAME, F_OK) == -1) { if (errno != ENOENT) { mce_log(LL_CRIT, "access() failed: %s. Exiting.", g_strerror(errno)); goto EXIT; } mce_write_string_to_file(MCE_MALF_FILENAME, ENABLED_STRING); } } } else { mce_log(LL_CRIT, "access() failed: %s. Exiting.", g_strerror(errno)); goto EXIT; } } else { if (g_access(MALF_FILENAME, F_OK) == 0) { if (g_access(MCE_MALF_FILENAME, F_OK) == 0) { mce_add_submode_int32(MCE_SUBMODE_MALF); mce_log(LL_DEBUG, "Malf mode enabled"); } } else if ((errno == ENOENT) && (g_access(MCE_MALF_FILENAME, F_OK) == 0)) { g_remove(MCE_MALF_FILENAME); } } status = TRUE; EXIT: return status; }
const char* FerryRegionSymbolImpl::GetIcon() { char icon_path[AUGE_PATH_MAX]; memset(icon_path, 0, AUGE_PATH_MAX); auge_make_symbol_icon_path(m_icon_name.c_str(), icon_path, AUGE_PATH_MAX); if(g_access(icon_path,4)) { DrawIcon(); SaveIcon(icon_path); } return m_icon_name.c_str(); }