// Ls is a Multistream muxer command which returns the list of handler names
// available on a muxer.
320493
func Ls(rw io.ReadWriter) ([]string, error) {
	err := delimWriteBuffered(rw, []byte("ls"))
	if err != nil {
		return nil, err
	}

	n, err := binary.ReadUvarint(&byteReader{rw})
	if err != nil {
		return nil, err
	}

	var out []string
	for i := uint64(0); i < n; i++ {
		val, err := lpReadBuf(rw)
		if err != nil {
			return nil, err
		}
		out = append(out, string(val))
	}

	return out, nil
}
978830
func ListServices(filters []string) (services []Service, err error) {
	launchAgentDir := launchAgentDir()
	if _, derr := os.Stat(launchAgentDir); os.IsNotExist(derr) {
		return
	}
	files, err := ioutil.ReadDir(launchAgentDir)
	if err != nil {
		return
	}
	for _, f := range files {
		fileName := f.Name()
		suffix := ".plist"
		// We care about services that contain the filter word and end in .plist
		for _, filter := range filters {
			if strings.HasPrefix(fileName, filter) && strings.HasSuffix(fileName, suffix) {
				label := fileName[0 : len(fileName)-len(suffix)]
				service := NewService(label)
				services = append(services, service)
			}
		}
	}
	return
}
1084011
func (m *nativeGitClient) LsFiles(path string) ([]string, error) {
	out, err := m.runCmd("git", "ls-files", "--full-name", "-z", "--", path)
	if err != nil {
		return nil, err
	}
	// remove last element, which is blank regardless of whether we're using nullbyte or newline
	ss := strings.Split(out, "\000")
	return ss[:len(ss)-1], nil
}
474679
func (s *Server) RunTLS(addr string, config *tls.Config) error {
	s.initServer()
	mux := http.NewServeMux()
	mux.Handle("/", s)

	l, err := tls.Listen("tcp", addr, config)
	if err != nil {
		log.Fatal("Listen:", err)
		return err
	}
	s.Logger.Printf("web.go serving %s\n", l.Addr())

	s.l = l
	return http.Serve(s.l, mux)
}
219495
func (c *Client) ListPools(providers, names []string) ([]params.StoragePool, error) {
	args := params.StoragePoolFilters{
		Filters: []params.StoragePoolFilter{{
			Names:     names,
			Providers: providers,
		}},
	}
	var results params.StoragePoolsResults
	if err := c.facade.FacadeCall("ListPools", args, &results); err != nil {
		return nil, errors.Trace(err)
	}
	if len(results.Results) != 1 {
		return nil, errors.Errorf("expected 1 result, got %d", len(results.Results))
	}
	if err := results.Results[0].Error; err != nil {
		return nil, err
	}
	return results.Results[0].Result, nil
}
321631
func (c *Client) ListFolders(name string) ([]os.FileInfo, error) {
	return c.ListFilter(name, func(info os.FileInfo) bool {
		return info.IsDir()
	})
}
1045666
func libs(binpath string) []string {
	f, err := elf.Open(binpath)
	if err != nil {
		return []string{}
	}
	libraries, _ := f.ImportedLibraries()
	return libraries
}
642997
func Handle(mux *http.ServeMux, prefix string, handler Handler) {
	HandleAnnotations(mux, prefix, handler)
	HandleQuery(mux, prefix, handler)
	HandleSearch(mux, prefix, handler)

	// Registering a global handler is a common thing that applications do, to
	// avoid overriding one that may already exist we first check that none were
	// previously registered.
	root := path.Join("/", prefix)

	if _, pattern := mux.Handler(&http.Request{
		URL: &url.URL{Path: root},
	}); len(pattern) == 0 {
		mux.HandleFunc(root, func(res http.ResponseWriter, req *http.Request) {
			setResponseHeaders(res)
		})
	}
}
279205
func (o *Me) L4Services(info *bambou.FetchingInfo) (L4ServicesList, *bambou.Error) {

	var list L4ServicesList
	err := bambou.CurrentSession().FetchChildren(o, L4ServiceIdentity, &list, info)
	return list, err
}
129758
func Compresses(exts []string) HandlerFunc {
	extsmap := make(map[string]bool)
	for _, ext := range exts {
		extsmap[strings.ToLower(ext)] = true
	}

	return func(ctx *Context) {
		ae := ctx.Req().Header.Get("Accept-Encoding")
		if ae == "" {
			ctx.Next()
			return
		}

		if len(extsmap) > 0 {
			ext := strings.ToLower(path.Ext(ctx.Req().URL.Path))
			if _, ok := extsmap[ext]; ok {
				compress(ctx, "auto")
				return
			}
		}

		if action := ctx.Action(); action != nil {
			if c, ok := action.(Compresser); ok {
				compress(ctx, c.CompressType())
				return
			}
		}

		// if blank, then no compress
		ctx.Next()
	}
}
113579
func (mux *Mux) handler() *handler {
	return &handler{
		mux: mux,
		c:   make(chan net.Conn),
	}
}
40201
func resolveStreams(c context.Context, options userOptions) ([]*coordinator.LogStream, error) {
	prefix, name := options.path.Split()
	streams := []*coordinator.LogStream{}
	var err error
	if options.wildcard {
		q := datastore.NewQuery("LogStream").Eq("Prefix", prefix.String()).Eq("Purged", false)
		err = datastore.GetAll(c, q, &streams)
	} else {
		streams = append(streams, &coordinator.LogStream{ID: coordinator.LogStreamID(options.path)})
		err = datastore.Get(c, streams[0])
	}

	switch {
	case len(streams) == 0, datastore.IsErrNoSuchEntity(err):
		return nil, coordinator.ErrPathNotFound
	case err != nil:
		return nil, err
	case !options.wildcard:
		// If the user requested HTML format, check to see if the stream is a binary or datagram stream.
		// If so, then this mode is not supported, and instead just render a link to the supported mode.
		if options.isHTML() && streams[0].StreamType != logpb.StreamType_TEXT {
			err = errRawRedirect
		}
		return streams, err
	}

	result := matchStreams(streams, name.String())
	if len(result) == 0 {
		return nil, coordinator.ErrPathNotFound
	}
	return result, nil
}
1203860
func (r *Request) lsNext() int64 {
	r.state.RLock()
	defer r.state.RUnlock()
	return r.state.lsoffset
}
709184
func (mux *ServeMux) Handle(m Matcher, h Handler) {
	mux.handle(&muxEntry{m, h, false})
}
807612
func (fsh *Handler) GetFileNames(paths []string) (files []string, err error) {
	for _, path := range paths {
		err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
			if err != nil {
				return err
			}
			if info == nil || info.IsDir() {
				return nil
			}
			files = append(files, path)
			return nil
		})
		if err != nil {
			err = errors.Errorf("failed to traverse through %s: %v", path, err)
		}
	}
	return files, err
}
998520
func runLs(dirname string, dirent os.FileInfo) string {
	dsys := dirent.Sys()
	if dsys == nil {
	} else if statt, ok := dsys.(*syscall.Stat_t); !ok {
	} else {
		return runLsStatt(dirent, statt)
	}

	return path.Join(dirname, dirent.Name())
}
588563
func ListServices() ([]string, error) {
	fis, err := ioutil.ReadDir(InitDir)
	if err != nil {
		return nil, errors.Trace(err)
	}

	var services []string
	for _, fi := range fis {
		if groups := servicesRe.FindStringSubmatch(fi.Name()); len(groups) > 0 {
			services = append(services, groups[1])
		}
	}
	return services, nil
}