// MakeDirs is a convenience wrapper around os.MkdirAll that applies a 0755
// mask to all created directories.
768726
func MakeDirs(path string) error {
	if err := os.MkdirAll(path, 0755); err != nil {
		return errors.Annotate(err, "").Err()
	}
	return nil
}
373054
func (c *Client) Mkdir(dirname string, perm os.FileMode) error {
	return c.mkdir(dirname, perm, false)
}
64934
func MakeDirs(conn ZookeeperConnection, path string, makeLastNode bool, aclProvider ACLProvider) error {
	if err := ValidatePath(path); err != nil {
		return err
	}

	pos := 1 // skip first slash, root is guaranteed to exist

	for pos < len(path) {
		if idx := strings.Index(path[pos+1:], PATH_SEPARATOR); idx == -1 {
			if makeLastNode {
				pos = len(path)
			} else {
				return nil
			}
		} else {
			pos += idx + 1
		}

		subPath := path[:pos]

		if exists, _, err := conn.Exists(subPath); err != nil {
			return err
		} else if !exists {
			var acls []zk.ACL

			if aclProvider != nil {
				if acls = aclProvider.GetAclForPath(subPath); len(acls) == 0 {
					acls = aclProvider.GetDefaultAcl()
				}
			}

			if acls == nil {
				acls = OPEN_ACL_UNSAFE
			}

			if _, err := conn.Create(subPath, []byte{}, int32(PERSISTENT), acls); err != nil && err != zk.ErrNodeExists {
				return err
			}
		}
	}

	return nil
}
1092856
func createSecretDir(dir string) error {
	// Only mount the tmpfs if we are root
	if unix.Geteuid() == 0 {
		if err := os.MkdirAll(dir, 0777); err != nil {
			return err
		}

		// Check for marker file and skip mounting if it exists
		marker := filepath.Join(dir, secretMarker)
		if _, err := os.Stat(marker); err == nil {
			return nil
		}

		var flags uintptr
		flags = syscall.MS_NOEXEC
		options := fmt.Sprintf("size=%dm", secretDirTmpfsSize)
		if err := syscall.Mount("tmpfs", dir, "tmpfs", flags, options); err != nil {
			return os.NewSyscallError("mount", err)
		}

		// Create the marker file so we don't try to mount more than once
		f, err := os.OpenFile(marker, os.O_RDWR|os.O_CREATE, 0666)
		if err != nil {
			// Hard fail since if this fails something is really wrong
			return err
		}
		f.Close()
		return nil
	}

	return os.MkdirAll(dir, 0777)
}
880478
func MkDir(dirpath string) error {
	if PathExists(dirpath) {
		return nil
	}

	err := os.MkdirAll(dirpath, 0755)
	if err != nil {
		log.Println("Error creating directory")
		log.Println(err)
		return err
	}

	return nil
}
434900
func ensureDirectories(home helmpath.Home, out io.Writer) error {
	configDirectories := []string{
		home.String(),
		home.Repository(),
		home.Cache(),
		home.LocalRepository(),
		home.Plugins(),
		home.Starters(),
		home.Archive(),
	}
	for _, p := range configDirectories {
		if fi, err := os.Stat(p); err != nil {
			fmt.Fprintf(out, "Creating %s \n", p)
			if err := os.MkdirAll(p, 0755); err != nil {
				return fmt.Errorf("Could not create %s: %s", p, err)
			}
		} else if !fi.IsDir() {
			return fmt.Errorf("%s must be a directory", p)
		}
	}

	return nil
}
444834
func (s *blockDiskStore) makeDir(id kbfsblock.ID) error {
	err := ioutil.MkdirAll(s.blockPath(id), 0700)
	if err != nil {
		return err
	}

	// TODO: Only write if the file doesn't exist.

	return ioutil.WriteFile(s.idPath(id), []byte(id.String()), 0600)
}
799216
func ChangesDirs(newDir, oldDir string) ([]Change, error) {
	var (
		oldRoot, newRoot *FileInfo
	)
	if oldDir == "" {
		emptyDir, err := ioutil.TempDir("", "empty")
		if err != nil {
			return nil, err
		}
		defer os.Remove(emptyDir)
		oldDir = emptyDir
	}
	oldRoot, newRoot, err := collectFileInfoForChanges(oldDir, newDir)
	if err != nil {
		return nil, err
	}

	return newRoot.Changes(oldRoot), nil
}
1029863
func (fs MountFS) Mkdir(name string, perm os.FileMode) error {
	mount, innerPath := findMount(name, fs.mounts, fs.rootFS, string(fs.PathSeparator()))
	return mount.Mkdir(innerPath, perm)
}
1150129
func createConfigDir() error {
	var err error

	if _, err = os.Stat(ConfigDir()); os.IsNotExist(err) {
		log.Info(fmt.Sprintf("config dir '%s' does not exist", ConfigDir()))
		log.Info("creating the data dir...")

		if err = os.MkdirAll(ConfigDir(), 0755); err != nil {
			return err
		}

		log.Success("config dir successfully created")
	} else if err != nil {
		return err
	}

	if err = createConfigFile(); err != nil {
		return err
	}

	return nil
}
769900
func (fs OsFS) Mkdir(name string, perm os.FileMode) error {
	return os.Mkdir(name, perm)
}
189796
func (lfs localFileSystem) Mkdir(path string, perm os.FileMode) error {
	return villa.Path(path).MkdirAll(perm)
}
1169159
func NewDirectory(containerName string) (directory string, err error) {
	directory = dirForName(containerName)
	logger.Tracef("create directory: %s", directory)
	if err = os.MkdirAll(directory, 0755); err != nil {
		logger.Errorf("failed to create container directory: %v", err)
		return "", err
	}
	return directory, nil
}
991223
func parentDirs(rel string, cb func(p string) bool) {
	for i, r := range rel {
		if r == filepath.Separator && !cb(rel[:i]) {
			return
		}
	}
}
1108150
func (n *Mounter) MakeDir(pathname string) error {
	args := []string{"-p", pathname}
	if _, err := n.ne.Exec("mkdir", args).CombinedOutput(); err != nil {
		return err
	}
	return nil
}
762057
func (fs *FS) Mkdir(name string, perm os.FileMode) error {
	return fs.Filesystem.Mkdir(fs.PrefixPath(name), perm)
}
159619
func MkdirAll(dirpath string) error {
	// TODO: am I swallowing err?
	if _, err := os.Stat(dirpath); os.IsNotExist(err) {
		return os.MkdirAll(dirpath, os.ModeDir|0700)
	}
	return nil
}