// Chcon changes the `fpath` file object to the SELinux label `label`.
// If `fpath` is a directory and `recurse`` is true, Chcon will walk the
// directory tree setting the label.
493631
func Chcon(fpath string, label string, recurse bool) error {
	if fpath == "" {
		return ErrEmptyPath
	}
	if label == "" {
		return nil
	}
	if err := badPrefix(fpath); err != nil {
		return err
	}
	callback := func(p string, info os.FileInfo, err error) error {
		e := SetFileLabel(p, label)
		if os.IsNotExist(e) {
			return nil
		}
		return e
	}

	if recurse {
		return filepath.Walk(fpath, callback)
	}

	return SetFileLabel(fpath, label)
}
37369
func (container *Container) ConfigFilePath(configRef swarmtypes.ConfigReference) (string, error) {
	mounts, err := container.SecretMountPath()
	if err != nil {
		return "", err
	}
	return filepath.Join(mounts, configRef.ConfigID), nil
}
981039
func (cds *ChaincodeDeploymentSpec) Path() string {
	if cds.ChaincodeSpec == nil {
		return ""
	}

	return cds.ChaincodeSpec.Path()
}
1283704
func CriuPath(criupath string) func(*LinuxFactory) error {
	return func(l *LinuxFactory) error {
		l.CriuPath = criupath
		return nil
	}
}
352168
func (_m *DFS) DfPath(path string, excludes []string) (uint64, error) {
	ret := _m.Called(path, excludes)

	var r0 uint64
	if rf, ok := ret.Get(0).(func(string, []string) uint64); ok {
		r0 = rf(path, excludes)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(uint64)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string, []string) error); ok {
		r1 = rf(path, excludes)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
115221
func (RealOS) Chmod(path string, perm os.FileMode) error {
	return os.Chmod(path, perm)
}
829859
func (s *Store) Fsck(ctx context.Context, path string) error {
	var result error

	for alias, sub := range s.mounts {
		if sub == nil {
			continue
		}
		if path != "" && !strings.HasPrefix(path, alias+"/") {
			continue
		}
		path = strings.TrimPrefix(path, alias+"/")
		out.Debug(ctx, "root.Fsck() - Checking %s", alias)
		if err := sub.Fsck(ctx, path); err != nil {
			out.Error(ctx, "fsck failed on sub store %s: %s", alias, err)
			result = multierror.Append(result, err)
		}
	}
	if err := s.store.Fsck(ctx, path); err != nil {
		out.Error(ctx, "fsck failed on root store: %s", err)
		result = multierror.Append(result, err)
	}

	return result
}
532740
func (h Home) Path(elem ...string) string {
	p := []string{h.String()}
	p = append(p, elem...)
	return filepath.Join(p...)
}
55381
func File(path string) func(ctx *Context) {
	return func(ctx *Context) {
		ctx.ServeFile(path)
	}
}
635277
func (p *Importer) absPath(path string) (string, error) {
	// TODO(gri) This should be using p.ctxt.AbsPath which doesn't
	// exist but probably should. See also issue #14282.
	return filepath.Abs(path)
}
1058758
func Chmod(filePath string, mode os.FileMode) error {
	stat, err := os.Lstat(filePath)
	if err != nil {
		return err
	}

	if stat.IsDir() {
		files, err := ioutil.ReadDir(filePath)
		if err != nil {
			return err
		}
		for _, file := range files {
			if err := Chmod(filePath+"/"+file.Name(), mode); err != nil {
				return err
			}
		}

		// Set executable rights for folders if read or write is allowed
		execRights := 0
		if mode&0600 != 0 {
			execRights |= 0100
		}
		if mode&0060 != 0 {
			execRights |= 0010
		}
		if mode&0006 != 0 {
			execRights |= 0001
		}

		return os.Chmod(filePath, mode|os.FileMode(execRights))
	}

	if stat.Mode()&os.ModeSymlink != 0 {
		// TODO: os.Chmod fails on symlinks
		return nil
	}

	return os.Chmod(filePath, mode)
}
121112
func (f *FolderConfiguration) CheckPath() error {
	fi, err := f.Filesystem().Stat(".")
	if err != nil {
		if !fs.IsNotExist(err) {
			return err
		}
		return ErrPathMissing
	}

	// Users might have the root directory as a symlink or reparse point.
	// Furthermore, OneDrive bullcrap uses a magic reparse point to the cloudz...
	// Yet it's impossible for this to happen, as filesystem adds a trailing
	// path separator to the root, so even if you point the filesystem at a file
	// Stat ends up calling stat on C:\dir\file\ which, fails with "is not a directory"
	// in the error check above, and we don't even get to here.
	if !fi.IsDir() && !fi.IsSymlink() {
		return ErrPathNotDirectory
	}

	_, err = f.Filesystem().Stat(f.MarkerName)
	if err != nil {
		if !fs.IsNotExist(err) {
			return err
		}
		return ErrMarkerMissing
	}

	return nil
}
588989
func (d *manifestDeployer) CharmPath(path string) string {
	return filepath.Join(d.charmPath, path)
}
126069
func (ccpack *SignedCDSPackage) InitFromPath(ccname string, ccversion string, path string) ([]byte, *pb.ChaincodeDeploymentSpec, error) {
	//incase ccpack is reused
	ccpack.reset()

	buf, err := GetChaincodePackageFromPath(ccname, ccversion, path)
	if err != nil {
		return nil, nil, err
	}

	if _, err = ccpack.InitFromBuffer(buf); err != nil {
		return nil, nil, err
	}

	return ccpack.buf, ccpack.depSpec, nil
}
484106
func (p FileInfoSlice) Labels() []string {
	// This would probably be very slightly more efficient with a heap, but the
	// API would be more complicated
	sort.Sort(p)
	labels := make([]string, p.Len())
	for i, label := range p {
		labels[i] = label.Name()
	}
	return labels
}
338693
func RelativePathToTarget(path string) (rel string, recurse bool, err error) {
	// Detect recursion
	if strings.HasSuffix(path, string(os.PathSeparator)+"...") {
		recurse = true
		path = path[:len(path)-len(string(os.PathSeparator)+"...")]
	}

	// If path is unset, use local directory
	if path == "" || path == "." {
		return ".", recurse, nil
	}

	if _, err := os.Stat(path); err != nil {
		if perr, ok := err.(*os.PathError); ok {
			if serr, ok := perr.Err.(syscall.Errno); ok {
				if serr == syscall.ENOENT { // we might be given a import path.
					var err error
					path, err = findRelativeFromImport(path)
					if err != nil {
						return "", false, err
					}
					return path, recurse, nil
				}
			}
		}
		return "", false, err
	}
	return path, recurse, nil
}
1171495
func LocalConfigFileAbsolutePath() (string, error) {
	configDir, err := LocalConfigDirectoryAbsolutePath()
	if err != nil {
		return "", err
	}
	return filepath.Join(configDir, LocalConfigFilename), nil
}