// TailName returns the name of the final node in the Path. Must be
// called with a valid path.
543471
func (p Path) TailName() string {
	return p.Path[len(p.Path)-1].Name
}
1021349
func (f *DatastoreFile) Tail(n int) error {
	return f.TailFunc(n, func(line int, _ string) bool { return n > line })
}
198638
func BaseName(path string) string {
	base := filepath.Base(path)
	ext := filepath.Ext(path)

	re := regexp.MustCompile(ext + "$")
	return re.ReplaceAllString(base, "")
}
240202
func (info *nodeInfo) prettyName() string {
	var name string
	if info.address != 0 {
		name = fmt.Sprintf("%016x", info.address)
	}

	if info.name != "" {
		name = name + " " + info.name
	}

	if info.file != "" {
		name += " " + trimPath(info.file)
		if info.lineno != 0 {
			name += fmt.Sprintf(":%d", info.lineno)
		}
	}

	if info.inline {
		name = name + " (inline)"
	}

	if name = strings.TrimSpace(name); name == "" && info.objfile != "" {
		name = "[" + info.objfile + "]"
	}
	return name
}
876422
func (f *DatastoreFile) TailFunc(lines int, include func(line int, message string) bool) error {
	// Read the file in reverse using bsize chunks
	const bsize = int64(1024 * 16)

	fsize, err := f.Seek(0, io.SeekEnd)
	if err != nil {
		return err
	}

	if lines == 0 {
		return nil
	}

	chunk := int64(-1)

	buf := bytes.NewBuffer(make([]byte, 0, bsize))
	line := 0

	for {
		var eof bool
		var pos int64

		nread := bsize

		offset := chunk * bsize
		remain := fsize + offset

		if remain < 0 {
			if pos, err = f.Seek(0, io.SeekStart); err != nil {
				return err
			}

			nread = bsize + remain
			eof = true
		} else if pos, err = f.Seek(offset, io.SeekEnd); err != nil {
			return err
		}

		if _, err = io.CopyN(buf, f, nread); err != nil {
			if err != io.EOF {
				return err
			}
		}

		b := buf.Bytes()
		idx, done := lastIndexLines(b, &line, include)

		if done {
			if chunk == -1 {
				// We found all N lines in the last chunk of the file.
				// The seek offset is also now at the current end of file.
				// Save this buffer to avoid another GET request when Read() is called.
				buf.Next(int(idx + 1))
				f.buf = buf
				return nil
			}

			if _, err = f.Seek(pos+idx+1, io.SeekStart); err != nil {
				return err
			}

			break
		}

		if eof {
			if remain < 0 {
				// We found < N lines in the entire file, so seek to the start.
				_, _ = f.Seek(0, io.SeekStart)
			}
			break
		}

		chunk--
		buf.Reset()
	}

	return nil
}
210328
func funcname(name string) string {
	i := strings.LastIndex(name, "/")
	name = name[i+1:]
	i = strings.Index(name, ".")
	return name[i+1:]
}
441641
func (s *GetEventSelectorsInput) SetTrailName(v string) *GetEventSelectorsInput {
	s.TrailName = &v
	return s
}
336592
func (clstr *Cluster) GetNodeByName(nodeName string) (*Node, error) {
	node := clstr.findNodeByName(nodeName)

	if node == nil {
		return nil, NewAerospikeError(INVALID_NODE_ERROR, "Invalid node name"+nodeName)
	}
	return node, nil
}
924768
func (s *Storage) Tail(c context.Context, project types.ProjectName, path types.StreamPath) (*storage.Entry, error) {
	var r *rec

	// Find the latest log, then return it.
	err := s.run(func() error {
		ls := s.getLogStreamLocked(project, path, false)
		if ls == nil {
			return storage.ErrDoesNotExist
		}

		r = &rec{
			index: ls.latestIndex,
			data:  ls.logs[ls.latestIndex],
		}
		return nil
	})
	if err != nil {
		return nil, err
	}
	return storage.MakeEntry(r.data, r.index), nil
}
728314
func (c *Config) NodeName() string {
	name := c.name()
	// Backwards compatibility: previous versions used title-cased "Geth", keep that.
	if name == "geth" || name == "geth-testnet" {
		name = "Geth"
	}
	if c.UserIdent != "" {
		name += "/" + c.UserIdent
	}
	if c.Version != "" {
		name += "/v" + c.Version
	}
	name += "/" + runtime.GOOS + "-" + runtime.GOARCH
	name += "/" + runtime.Version()
	return name
}
936192
func deriveName(root, full string) string {
	short, _ := filepath.Rel(root, full)
	bits := strings.Split(short, string(os.PathSeparator))
	return strings.Join(bits, "-")
}
1158983
func (d *Dir) RemoveNodeByName(name string) error {
	for i := 0; i < len(d.nodes); i++ {
		if d.nodes[i].Name() == name {
			d.nodes = append(d.nodes[:i], d.nodes[i+1:]...)
			return nil
		}
	}
	return fmt.Errorf("Con not find node to remove (by name " + name + ")")
}
1265351
func (fn *Function) BaseName() string {
	if i := strings.LastIndex(fn.Name, "."); i != -1 {
		return fn.Name[i+1:]
	}
	return fn.Name
}
537610
func GetRebaseName(path, resolvedPath string) (string, string) {
	// linkTarget will have been cleaned (no trailing path separators and dot) so
	// we can manually join it with them
	var rebaseName string
	if specifiesCurrentDir(path) && !specifiesCurrentDir(resolvedPath) {
		resolvedPath += string(filepath.Separator) + "."
	}

	if hasTrailingPathSeparator(path) && !hasTrailingPathSeparator(resolvedPath) {
		resolvedPath += string(filepath.Separator)
	}

	if filepath.Base(path) != filepath.Base(resolvedPath) {
		// In the case where the path had a trailing separator and a symlink
		// evaluation has changed the last path component, we will need to
		// rebase the name in the archive that is being copied to match the
		// originally requested name.
		rebaseName = filepath.Base(path)
	}
	return resolvedPath, rebaseName
}
36597
func SegmentName(dir string, i int) string {
	return filepath.Join(dir, fmt.Sprintf("%08d", i))
}
35835
func (v *Vibranium) GetNodeByName(ctx context.Context, opts *pb.GetNodeOptions) (*pb.Node, error) {
	n, err := v.cluster.GetNodeByName(ctx, opts.Nodename)
	if err != nil {
		return nil, err
	}

	return toRPCNode(ctx, n), nil
}
903148
func (s *User) SetLastName(v string) *User {
	s.LastName = &v
	return s
}