// Dir implements Storage.Dir
432469
func (s *FolderStorage) Dir(key string) (d string, e bool, err error) {
	d = s.dir(key)
	_, err = os.Stat(d)
	if err == nil {
		// Directory exists
		e = true
		return
	}
	if os.IsNotExist(err) {
		// Directory doesn't exist
		d = ""
		e = false
		err = nil
		return
	}

	// An error
	d = ""
	e = false
	return
}
613130
func (d *AllocDir) List(path string) ([]*cstructs.AllocFileInfo, error) {
	if escapes, err := structs.PathEscapesAllocDir("", path); err != nil {
		return nil, fmt.Errorf("Failed to check if path escapes alloc directory: %v", err)
	} else if escapes {
		return nil, fmt.Errorf("Path escapes the alloc directory")
	}

	p := filepath.Join(d.AllocDir, path)
	finfos, err := ioutil.ReadDir(p)
	if err != nil {
		return []*cstructs.AllocFileInfo{}, err
	}
	files := make([]*cstructs.AllocFileInfo, len(finfos))
	for idx, info := range finfos {
		files[idx] = &cstructs.AllocFileInfo{
			Name:     info.Name(),
			IsDir:    info.IsDir(),
			Size:     info.Size(),
			FileMode: info.Mode().String(),
			ModTime:  info.ModTime(),
		}
	}
	return files, err
}
376779
func (client *storageRESTClient) ListDir(volume, dirPath string, count int, leafFile string) (entries []string, err error) {
	values := make(url.Values)
	values.Set(storageRESTVolume, volume)
	values.Set(storageRESTDirPath, dirPath)
	values.Set(storageRESTCount, strconv.Itoa(count))
	values.Set(storageRESTLeafFile, leafFile)
	respBody, err := client.call(storageRESTMethodListDir, values, nil, -1)
	if err != nil {
		return nil, err
	}
	defer http.DrainBody(respBody)
	err = gob.NewDecoder(respBody).Decode(&entries)
	return entries, err
}
407892
func (b *Bag) AddDir(src string) (errs []error) {
	payloadManifests := b.GetManifests(PayloadManifest)
	_, errs = b.payload.AddAll(src, payloadManifests)
	return errs
}
1282136
func CacheDir(appName string) (string, error) {
	if appName == "" {
		return "", fmt.Errorf("No app name for dir")
	}
	return filepath.Join(os.TempDir(), appName), nil
}
813402
func (l *localFileSystem) MkDir(path string, mode int) error {
	fileMode := os.FileMode(mode & int(os.ModePerm))
	err := os.MkdirAll(path, fileMode)
	if err != nil && !os.IsExist(err) {
		return trace.ConvertSystemError(err)
	}

	return nil
}
791882
func (d *Dir) Access(ctx context.Context, r *fuse.AccessRequest) (err error) {
	ctx = d.folder.fs.config.MaybeStartTrace(
		ctx, "Dir.Access", d.node.GetBasename())
	defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }()

	return d.folder.access(ctx, r)
}
158775
func (d *dir) mkdirs(p string) (*dir, error) {
	p = normalize(p)

	n := d.find(p)

	if !n.isdir() {
		// Found something there
		return nil, errIsNotDir
	}

	if n.path() == p {
		return n.(*dir), nil
	}

	dd := n.(*dir)

	relative := strings.Trim(strings.TrimPrefix(p, n.path()), "/")

	if relative == "" {
		return dd, nil
	}

	components := strings.Split(relative, "/")
	for _, component := range components {
		d, err := dd.mkdir(component)

		if err != nil {
			// This should actually never happen, since there are no children.
			return nil, err
		}
		dd = d
	}

	return dd, nil
}
789676
func (s *Store) TmpDir() (string, error) {
	dir := filepath.Join(s.dir, "tmp")
	if err := os.MkdirAll(dir, defaultPathPerm); err != nil {
		return "", err
	}
	return dir, nil
}
489301
func (d Dir) Path() string {
	if d.env == "" {
		panic("xdgdir.Dir.Path() on zero Dir")
	}
	p := d.path()
	if p != "" && d.userOwned {
		info, err := os.Stat(p)
		if err != nil {
			return ""
		}
		if !info.IsDir() || info.Mode().Perm() != 0700 {
			return ""
		}
		st, ok := info.Sys().(*syscall.Stat_t)
		if !ok || int(st.Uid) != geteuid() {
			return ""
		}
	}
	return p
}
624165
func DataDir() string {
	dataHome := filepath.Join(os.Getenv("HOME"), DefaultDataDir)
	if xdg := os.Getenv("XDG_DATA_HOME"); len(xdg) > 0 {
		dataHome = xdg
	}

	return filepath.Join(dataHome, DataFolder)
}
326597
func (c *Context) Mkdir(path string) error {
	if ae != nil {
		return ae.Mkdir(c.ae, path)
	}
	return c.mkdir(path)
}
471386
func (fs *fakeFs) ReadDir(dirname string) ([]os.FileInfo, error) {
	return fs.a.ReadDir(dirname)
}
40245
func (lfs localFileSystem) ReadDir(dir string) ([]os.FileInfo, error) {
	return villa.Path(dir).ReadDir()
}
210555
func (r *Registry) UserDirectory() *UserDirectory {
	return r.Get(r.content().UserDirectory.Reference()).(*UserDirectory)
}
912732
func (d *DiskStorer) All() ([]string, error) {
	files, err := ioutil.ReadDir(d.folderPath)
	if err != nil {
		return []string{}, errors.Wrapf(err, "unable to read directory: %s", d.folderPath)
	}

	sessions := make([]string, len(files))

	for i := 0; i < len(files); i++ {
		sessions[i] = files[i].Name()
	}

	return sessions, nil
}
1004727
func (wfe *WebFrontEndImpl) Directory(ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) {
	directoryEndpoints := map[string]interface{}{
		"new-reg":     newRegPath,
		"new-authz":   newAuthzPath,
		"new-cert":    newCertPath,
		"revoke-cert": revokeCertPath,
	}

	// Versions of Certbot pre-0.6.0 (named LetsEncryptPythonClient at the time) break when they
	// encounter a directory containing elements they don't expect so we gate
	// adding new directory fields for clients matching this UA.
	clientDirChangeIntolerant := strings.HasPrefix(request.UserAgent(), "LetsEncryptPythonClient")
	if !clientDirChangeIntolerant {
		directoryEndpoints["key-change"] = rolloverPath
	}
	if !clientDirChangeIntolerant {
		// Add a random key to the directory in order to make sure that clients don't hardcode an
		// expected set of keys. This ensures that we can properly extend the directory when we
		// need to add a new endpoint or meta element.
		directoryEndpoints[core.RandomString(8)] = randomDirKeyExplanationLink

		// ACME since draft-02 describes an optional "meta" directory entry. The
		// meta entry may optionally contain a "terms-of-service" URI for the
		// current ToS.
		metaMap := map[string]interface{}{
			"terms-of-service": wfe.SubscriberAgreementURL,
		}
		// The "meta" directory entry may also include a []string of CAA identities
		if wfe.DirectoryCAAIdentity != "" {
			// The specification says caaIdentities is an array of strings. In
			// practice Boulder's VA only allows configuring ONE CAA identity. Given
			// that constraint it doesn't make sense to allow multiple directory CAA
			// identities so we use just the `wfe.DirectoryCAAIdentity` alone.
			metaMap["caaIdentities"] = []string{
				wfe.DirectoryCAAIdentity,
			}
		}
		// The "meta" directory entry may also include a string with a website URL
		if wfe.DirectoryWebsite != "" {
			metaMap["website"] = wfe.DirectoryWebsite
		}
		directoryEndpoints["meta"] = metaMap
	}

	response.Header().Set("Content-Type", "application/json")

	relDir, err := wfe.relativeDirectory(request, directoryEndpoints)
	if err != nil {
		marshalProb := probs.ServerInternal("unable to marshal JSON directory")
		wfe.sendError(response, logEvent, marshalProb, nil)
		return
	}

	response.Write(relDir)
}