apr_array_header_t *arrayOfStringsFromListOfStrings( Py::Object arg, SvnPool &pool ) { Py::List paths( arg ); int num_targets = paths.length(); apr_array_header_t *array = apr_array_make( pool, num_targets, sizeof( const char * ) ); std::string type_error_message; try { Py::List path_list( arg ); for( Py::List::size_type i=0; i<path_list.length(); i++ ) { type_error_message = "expecting list members to be strings"; Py::Bytes str( asUtf8Bytes( path_list[i] ) ); *(char **)apr_array_push( array ) = apr_pstrdup( pool, str.as_std_string().c_str() ); } } catch( Py::TypeError & ) { throw Py::TypeError( type_error_message ); } return array; }
static void path_list_recursive_append(GList **list, GList *dirs) { GList *work; work = dirs; while (work) { const gchar *path = work->data; GList *f = NULL; GList *d = NULL; if (path_list(path, &f, &d)) { f = path_list_filter(f, FALSE); f = path_list_sort(f); *list = g_list_concat(*list, f); d = path_list_filter(d, TRUE); d = path_list_sort(d); path_list_recursive_append(list, d); path_list_free(d); } work = work->next; } }
/* sorry for complexity (cm->done_list), but need it to remove empty dirs */ void cache_maintain_home (CacheType type, gint clear) { CMData *cm; GList *dlist = NULL; gchar *base; const gchar *msg; if (type == CACHE_THUMBS) base = g_strconcat (home_dir (), "/", PORNVIEW_RC_DIR_THUMBS, NULL); else base = g_strconcat (home_dir (), "/", PORNVIEW_RC_DIR_COMMENTS, NULL); if (!path_list (base, NULL, &dlist)) { g_free (base); return; } dlist = g_list_append (dlist, base); cm = g_new0 (CMData, 1); cm->list = dlist; cm->done_list = NULL; cm->clear = clear; cm->type = type; if (clear) { if (type == CACHE_THUMBS) msg = _("Clearing thumbnails..."); else msg = _("Clearing comments..."); } else { if (type == CACHE_THUMBS) msg = _("Purging old thumbnails..."); else msg = _("Purging old comments..."); } if (type == CACHE_THUMBS) cm->gd = generic_dialog_new (_("Purge thumbnails"), msg, "PornView", "purge_thumbnails", TRUE, cb_cache_maintain_home_cancel, cm); else cm->gd = generic_dialog_new (_("Purge comments"), msg, "PornView", "purge_comments", TRUE, cb_cache_maintain_home_cancel, cm); gtk_window_set_position (GTK_WINDOW (cm->gd->dialog), GTK_WIN_POS_CENTER); gtk_widget_set_usize (cm->gd->dialog, PURGE_DIALOG_WIDTH, -1); cm->entry = gtk_entry_new (); gtk_widget_set_sensitive (cm->entry, FALSE); gtk_box_pack_start (GTK_BOX (cm->gd->vbox), cm->entry, FALSE, FALSE, 5); gtk_widget_show (cm->entry); gtk_widget_show (cm->gd->dialog); cm->idle_id = gtk_idle_add (cb_cache_maintain_home, cm); }
static void collect_manager_refresh(void) { GList *list = NULL; GList *work; gchar *base; base = g_strconcat(homedir(), "/", GQVIEW_RC_DIR_COLLECTIONS, NULL); path_list(base, &list, NULL); g_free(base); work = collection_manager_entry_list; while (work && list) { CollectManagerEntry *entry; GList *list_step; entry = work->data; work = work->next; list_step = list; while (list_step && entry) { gchar *path; path = list_step->data; list_step = list_step->next; if (strcmp(path, entry->path) == 0) { list = g_list_remove(list, path); g_free(path); entry = NULL; } else { collect_manager_entry_free(entry); } } } work = list; while (work) { gchar *path; path = work->data; work = work->next; collect_manager_entry_new(path); g_free(path); } g_list_free(list); }
GList *path_list_recursive(const gchar *path) { GList *list = NULL; GList *d = NULL; if (!path_list(path, &list, &d)) return NULL; list = path_list_filter(list, FALSE); list = path_list_sort(list); d = path_list_filter(d, TRUE); d = path_list_sort(d); path_list_recursive_append(&list, d); path_list_free(d); return list; }
apr_array_header_t *targetsFromStringOrList( Py::Object arg, SvnPool &pool ) { int num_targets = 1; if( arg.isList() ) { Py::List paths( arg ); num_targets = paths.length(); } apr_array_header_t *targets = apr_array_make( pool, num_targets, sizeof( const char * ) ); std::string type_error_message; try { if( arg.isList() ) { Py::List path_list( arg ); for( Py::List::size_type i=0; i<path_list.length(); i++ ) { type_error_message = "expecting path list members to be strings (arg 1)"; Py::Bytes path_str( asUtf8Bytes( path_list[i] ) ); std::string norm_path( svnNormalisedIfPath( path_str.as_std_string(), pool ) ); *(char **)apr_array_push( targets ) = apr_pstrdup( pool, norm_path.c_str() ); } } else { type_error_message = "expecting path to be a string (arg 1)"; Py::Bytes path_str( asUtf8Bytes( arg ) ); std::string norm_path( svnNormalisedIfPath( path_str.as_std_string(), pool ) ); *(char **)apr_array_push( targets ) = apr_pstrdup( pool, norm_path.c_str() ); } } catch( Py::TypeError & ) { throw Py::TypeError( type_error_message ); } return targets; }
void N3DView::send_server_info_to_client( SignalArgs& node ){ SignalFrame& options = node.map( Protocol::Tags::key_options() ); std::vector<std::string> data = options.get_array<std::string>("pathinfo"); std::string path = data[0]; std::string name = data[1]; std::vector<QString> path_list(1); path_list[0] = QString(path.c_str()); std::vector<QString> name_list(1); name_list[0] = QString(name.c_str()); TabBuilder::instance()->getWidget<Widget3D>(as_ptr<CNode>()) ->loadPaths(path_list, name_list); }
int big_manif(char **mav, t_path **path, t_env **lenv, t_cd *cd) { char **env; int check; check = compar_carac(mav); (*path) = NULL; fill_path(path, get_value_from_line(search_varenv((*lenv), "PATH"))); path_list(path, get_value_from_line(search_varenv((*lenv), "PWD"))); if (check == 0) check = check_spec(mav, lenv, cd); if (check == 0) { tabenv(*lenv, &env); my_exec((*path), mav, env); free_envtab(env); } return (check); }
Py::Object pysvn_client::cmd_proplist( const Py::Tuple &a_args, const Py::Dict &a_kws ) { static argument_description args_desc[] = { { true, name_url_or_path }, { false, name_revision }, { false, name_recurse }, #if defined( PYSVN_HAS_CLIENT_PROPLIST2 ) { false, name_peg_revision }, #endif #if defined( PYSVN_HAS_CLIENT_PROPLIST3 ) { false, name_depth }, { false, name_changelists }, #endif { false, NULL } }; FunctionArguments args( "proplist", args_desc, a_args, a_kws ); args.check(); Py::List path_list( toListOfStrings( args.getArg( name_url_or_path ) ) ); SvnPool pool( m_context ); #if defined( PYSVN_HAS_CLIENT_PROPLIST3 ) apr_array_header_t *changelists = NULL; if( args.hasArg( name_changelists ) ) { changelists = arrayOfStringsFromListOfStrings( args.getArg( name_changelists ), pool ); } svn_depth_t depth = args.getDepth( name_depth, name_recurse, svn_depth_files, svn_depth_empty ); #else bool recurse = args.getBoolean( name_recurse, false ); #endif bool is_revision_setup = false; bool is_url = false; svn_opt_revision_t revision_url; svn_opt_revision_t revision_file; if( args.hasArg( name_revision ) ) { revision_url = args.getRevision( name_revision ); revision_file = revision_url; } else { revision_url.kind = svn_opt_revision_head; revision_file.kind = svn_opt_revision_working; } #if defined( PYSVN_HAS_CLIENT_PROPLIST2 ) svn_opt_revision_t peg_revision_url; svn_opt_revision_t peg_revision_file; if( args.hasArg( name_peg_revision ) ) { peg_revision_url = args.getRevision( name_peg_revision ); peg_revision_file = peg_revision_url; } else { peg_revision_url = revision_url; peg_revision_file = revision_file; } #endif Py::List list_of_proplists; for( Py::List::size_type i=0; i<path_list.length(); i++ ) { Py::String path_str( asUtf8String( path_list[i] ) ); std::string path( path_str.as_std_string() ); std::string norm_path( svnNormalisedIfPath( path, pool ) ); svn_opt_revision_t revision; svn_opt_revision_t peg_revision; if( !is_revision_setup ) if( is_svn_url( path ) ) { revision = revision_url; #if defined( PYSVN_HAS_CLIENT_PROPLIST2 ) peg_revision = peg_revision_url; #endif is_url = true; } else { revision = revision_file; #if defined( PYSVN_HAS_CLIENT_PROPLIST2 ) peg_revision = peg_revision_file; #endif } else if( is_svn_url( path ) && !is_url ) { throw Py::AttributeError( "cannot mix URL and PATH in name_path" ); } try { const char *norm_path_c_str= norm_path.c_str(); checkThreadPermission(); PythonAllowThreads permission( m_context ); #if defined( PYSVN_HAS_CLIENT_PROPLIST3 ) ProplistReceiveBaton proplist_baton( &permission, pool, list_of_proplists ); svn_error_t *error = svn_client_proplist3 ( norm_path_c_str, &peg_revision, &revision, depth, changelists, proplist_receiver_c, reinterpret_cast<void *>( &proplist_baton ), m_context, pool ); #elif defined( PYSVN_HAS_CLIENT_PROPLIST2 ) apr_array_header_t *props = NULL; svn_error_t *error = svn_client_proplist2 ( &props, norm_path_c_str, &peg_revision, &revision, recurse, m_context, pool ); #else apr_array_header_t *props = NULL; svn_error_t *error = svn_client_proplist ( &props, norm_path_c_str, &revision, recurse, m_context, pool ); #endif permission.allowThisThread(); if( error != NULL ) throw SvnException( error ); #if !defined( PYSVN_HAS_CLIENT_PROPLIST3 ) proplistToObject( list_of_proplists, props, pool ); #endif } catch( SvnException &e ) { // use callback error over ClientException m_context.checkForError( m_module.client_error ); throw_client_error( e ); } } return list_of_proplists; }
/* This checks relative caches in dir/.thumbnails and * removes them if they have no source counterpart. */ gint cache_maintain_dir (CacheType type, const gchar * dir, gint recursive, gint clear) { GList *list = NULL; gchar *cachedir; gint still_have_a_file = FALSE; GList *work; if (type != CACHE_THUMBS) return FALSE; cachedir = g_strconcat (dir, "/", PORNVIEW_CACHE_DIR, NULL); path_list (cachedir, &list, NULL); work = list; while (work) { const gchar *path; gchar *source; path = work->data; work = work->next; source = g_strconcat (dir, "/", filename_from_path (path), NULL); if (clear || extension_truncate (source, PORNVIEW_CACHE_THUMB_EXT)) { if (!clear && isfile (source)) { still_have_a_file = TRUE; } else { if (unlink (path) < 0) { still_have_a_file = TRUE; } } } else { still_have_a_file = TRUE; } g_free (source); } path_list_free (list); g_free (cachedir); if (recursive) { list = NULL; path_list (dir, NULL, &list); work = list; while (work) { const gchar *path = work->data; work = work->next; still_have_a_file |= cache_maintain_dir (type, path, recursive, clear); } path_list_free (list); } return still_have_a_file; }
int cache_maintain_home_dir (CacheType type, const gchar * dir, gint recursive, gint clear) { gchar *base; gint base_length; GList *dlist = NULL; GList *flist = NULL; gint still_have_a_file = FALSE; if (type == CACHE_THUMBS) { base_length = strlen (home_dir ()) + strlen ("/") + strlen (PORNVIEW_RC_DIR_THUMBS); base = g_strconcat (home_dir (), "/", PORNVIEW_RC_DIR_THUMBS, dir, NULL); } else { base_length = strlen (home_dir ()) + strlen ("/") + strlen (PORNVIEW_RC_DIR_COMMENTS); base = g_strconcat (home_dir (), "/", PORNVIEW_RC_DIR_COMMENTS, dir, NULL); } if (path_list (base, &flist, &dlist)) { GList *work; work = dlist; while (work) { gchar *path = work->data; if (recursive && strlen (path) > base_length && !cache_maintain_home_dir (type, path + base_length, recursive, clear)) { if (rmdir (path) < 0) { printf ("Unable to delete dir: %s\n", path); } } else { still_have_a_file = TRUE; } work = work->next; } work = flist; while (work) { gchar *path = work->data; gchar *dot; dot = extension_find_dot (path); if (dot) *dot = '\0'; if (clear || (strlen (path) > base_length && !isfile (path + base_length))) { if (dot) *dot = '.'; if (unlink (path) < 0) printf ("failed to delete:%s\n", path); } else { still_have_a_file = TRUE; } work = work->next; } } path_list_free (dlist); path_list_free (flist); g_free (base); return still_have_a_file; }
static gint cb_cache_maintain_home (gpointer data) { CMData *cm = data; GList *dlist = NULL; GList *list = NULL; gchar *path; gint just_done = FALSE; gint still_have_a_file = TRUE; gint base_length; if (cm->type == CACHE_THUMBS) base_length = strlen (home_dir ()) + strlen ("/") + strlen (PORNVIEW_RC_DIR_THUMBS); else base_length = strlen (home_dir ()) + strlen ("/") + strlen (PORNVIEW_RC_DIR_COMMENTS); if (!cm->list) { cm->idle_id = -1; cache_maintain_home_close (cm); return FALSE; } path = cm->list->data; if (g_list_find (cm->done_list, path) == NULL) { cm->done_list = g_list_prepend (cm->done_list, path); if (path_list (path, &list, &dlist)) { GList *work; just_done = TRUE; still_have_a_file = FALSE; work = list; while (work) { gchar *path_buf = work->data; gchar *dot; dot = extension_find_dot (path_buf); if (dot) *dot = '\0'; if (cm->clear || (strlen (path_buf) > base_length && !isfile (path_buf + base_length))) { if (dot) *dot = '.'; if (unlink (path_buf) < 0) printf ("failed to delete:%s\n", path_buf); } else { still_have_a_file = TRUE; } work = work->next; } } } path_list_free (list); cm->list = g_list_concat (dlist, cm->list); if (cm->list && g_list_find (cm->done_list, cm->list->data) != NULL) { /* * check if the dir is empty */ if (cm->list->data == path && just_done) { if (!still_have_a_file && !dlist && cm->list->next && rmdir (path) < 0) { printf ("Unable to delete dir: %s\n", path); } } else { /* * must re-check for an empty dir */ path = cm->list->data; if (isempty (path) && cm->list->next && rmdir (path) < 0) { printf ("Unable to delete dir: %s\n", path); } } path = cm->list->data; cm->done_list = g_list_remove (cm->done_list, path); cm->list = g_list_remove (cm->list, path); g_free (path); } if (cm->list) { const gchar *buf; path = cm->list->data; if (strlen (path) > base_length) { buf = path + base_length; } else { buf = "..."; } gtk_entry_set_text (GTK_ENTRY (cm->entry), buf); } return TRUE; }