<commit_before>package libfuse

import (
	"bytes"
	"os"
	"regexp"
	"runtime/pprof"
	"time"

	"bazil.org/fuse"
	"bazil.org/fuse/fs"
	"golang.org/x/net/context"
)

// TODO: Implement in dokan.

// TODO: Also have a file for CPU profiles.

// ProfileListDirName is the name of the KBFS profile directory -- it
// can be reached from any KBFS directory.
const ProfileListDirName = ".kbfs_profiles"

// ProfileList is a node that can list all of the available profiles.
type ProfileList struct{}

var _ fs.Node = ProfileList{}

// Attr implements the fs.Node interface.
func (ProfileList) Attr(_ context.Context, a *fuse.Attr) error {
	a.Mode = os.ModeDir | 0755
	return nil
}

var _ fs.NodeRequestLookuper = ProfileList{}

// Lookup implements the fs.NodeRequestLookuper interface.
func (pl ProfileList) Lookup(_ context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (node fs.Node, err error) {
	p := pprof.Lookup(req.Name)
	if p == nil {
		return nil, fuse.ENOENT<commit_msg>libfuse: remove todo for dokan implementation of profilelist<commit_after>package libfuse

import (
	"bytes"
	"os"
	"regexp"
	"runtime/pprof"
	"time"

	"bazil.org/fuse"
	"bazil.org/fuse/fs"
	"golang.org/x/net/context"
)

// TODO: Also have a file for CPU profiles.

// ProfileListDirName is the name of the KBFS profile directory -- it
// can be reached from any KBFS directory.
const ProfileListDirName = ".kbfs_profiles"

// ProfileList is a node that can list all of the available profiles.
type ProfileList struct{}

var _ fs.Node = ProfileList{}

// Attr implements the fs.Node interface.
func (ProfileList) Attr(_ context.Context, a *fuse.Attr) error {
	a.Mode = os.ModeDir | 0755
	return nil
}

var _ fs.NodeRequestLookuper = ProfileList{}

// Lookup implements the fs.NodeRequestLookuper interface.
func (pl ProfileList) Lookup(_ context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (node fs.Node, err error) {
	p := pprof.Lookup(req.Name)
	if p == nil {
		return nil, fuse.ENOENT
{'fraction_non_alphanumeric': 0.11099949773982923, 'fraction_numerical': 0.004018081366147665, 'mean_word_length': 3.9675810473815463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4588648', 'n_tokens_mistral': 701, 'n_tokens_neox': 677, 'n_words': 216}