// Given a filepath, set it's permission bits directly
160060
func Chmod(filepath string, b PermissionBits) error {
	if e := syscall.Chmod(filepath, syscallMode(b)); e != nil {
		return &os.PathError{"chmod", filepath, e}
	}
	return nil
}
1162049
func (client *Client) SetConfigFile(fpath string) error {
	info, err := os.Stat(fpath)
	if err != nil {
		return err
	}
	if info.IsDir() {
		return fmt.Errorf("the specified config file path seems to be a directory")
	}
	client.ConfigFilePath = fpath

	client.flagForInit()

	return nil
}
439955
func (s *ListMailboxPermissionsOutput) SetPermissions(v []*Permission) *ListMailboxPermissionsOutput {
	s.Permissions = v
	return s
}
346444
func Stat(filepath string) (PermissionBits, error) {
	fi, err := os.Stat(filepath)
	if err != nil {
		return 0, err
	}
	return FileMode(fi.Mode()), nil
}
577344
func (d *Data) SetDirName(path, filename string, procs int) {
	if path == "" {
		d.dirname = fmt.Sprintf("_%s.%d", filename, procs)
	} else {
		d.dirname = fmt.Sprintf("%s/_%s.%d", path, filename, procs)
	}

}
1299954
func (s *CreateUserInput) SetPermissionsBoundary(v string) *CreateUserInput {
	s.PermissionsBoundary = &v
	return s
}
1296145
func (s *DiskInfo) SetPath(v string) *DiskInfo {
	s.Path = &v
	return s
}
857576
func LockedOpenFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
	return lockedOpenFile(path, flag, perm, syscall.F_SETLKW)
}
983536
func (s *DescribePermissionsOutput) SetPermissions(v []*Permission) *DescribePermissionsOutput {
	s.Permissions = v
	return s
}
433756
func WriteStringToFileWithPermission(pth string, fileCont string, perm os.FileMode) error {
	return WriteBytesToFileWithPermission(pth, []byte(fileCont), perm)
}
1351957
func (p *PDFProtection) SetProtection(permissions int, userPass []byte, ownerPass []byte) error {
	return p.setProtection(permissions, userPass, ownerPass)
}
452642
func (s *GetFolderInput) SetFolderPath(v string) *GetFolderInput {
	s.FolderPath = &v
	return s
}
1127105
func (s *ListPermissionsOutput) SetPermissions(v []*Permission) *ListPermissionsOutput {
	s.Permissions = v
	return s
}
1264138
func splitPath(path string) ([]fileInfo, error) {
	var mode os.FileMode
	fi, err := os.Stat(path)

	// If the path is not present in the host then we respond with the most
	// flexible permission.
	uid, gid := idUnsupported, idUnsupported
	if err != nil {
		mode = os.ModePerm
	} else {
		uid, gid = getOwner(fi)
		mode = fi.Mode()
	}
	var dirs []fileInfo
	dirs = append(dirs, fileInfo{Name: path, Perm: mode, Uid: uid, Gid: gid})
	currentDir := path
	for {
		dir := filepath.Dir(filepath.Clean(currentDir))
		if dir == currentDir {
			break
		}

		// We try to find the permission of the file in the host. If the path is not
		// present in the host then we respond with the most flexible permission.
		uid, gid := idUnsupported, idUnsupported
		fi, err := os.Stat(dir)
		if err != nil {
			mode = os.ModePerm
		} else {
			uid, gid = getOwner(fi)
			mode = fi.Mode()
		}
		dirs = append(dirs, fileInfo{Name: dir, Perm: mode, Uid: uid, Gid: gid})
		currentDir = dir
	}
	return dirs, nil
}
1061161
func (s *TargetGrant) SetPermission(v string) *TargetGrant {
	s.Permission = &v
	return s
}
1206413
func (s *DeleteFileInput) SetFilePath(v string) *DeleteFileInput {
	s.FilePath = &v
	return s
}
1017794
func (c *client) setPermissions(perms *Permissions) {
	if perms == nil {
		return
	}
	c.perms = &permissions{}
	c.perms.pcache = make(map[string]bool)

	// Loop over publish permissions
	if perms.Publish != nil {
		if len(perms.Publish.Allow) > 0 {
			c.perms.pub.allow = NewSublist()
		}
		for _, pubSubject := range perms.Publish.Allow {
			sub := &subscription{subject: []byte(pubSubject)}
			c.perms.pub.allow.Insert(sub)
		}
		if len(perms.Publish.Deny) > 0 {
			c.perms.pub.deny = NewSublist()
		}
		for _, pubSubject := range perms.Publish.Deny {
			sub := &subscription{subject: []byte(pubSubject)}
			c.perms.pub.deny.Insert(sub)
		}
	}

	// Loop over subscribe permissions
	if perms.Subscribe != nil {
		if len(perms.Subscribe.Allow) > 0 {
			c.perms.sub.allow = NewSublist()
		}
		for _, subSubject := range perms.Subscribe.Allow {
			sub := &subscription{subject: []byte(subSubject)}
			c.perms.sub.allow.Insert(sub)
		}
		if len(perms.Subscribe.Deny) > 0 {
			c.perms.sub.deny = NewSublist()
			// Also hold onto this array for later.
			c.darray = perms.Subscribe.Deny
		}
		for _, subSubject := range perms.Subscribe.Deny {
			sub := &subscription{subject: []byte(subSubject)}
			c.perms.sub.deny.Insert(sub)
		}
	}
}