// tempDir, if specified, will contain files that were replaced during an update
// and will be removed after an update. The temp dir should already exist.
348421
func (u *Updater) tempDir() string {
	tmpDir := util.TempPath("", "KeybaseUpdater.")
	if err := util.MakeDirs(tmpDir, 0700, u.log); err != nil {
		u.log.Warningf("Error trying to create temp dir: %s", err)
		return ""
	}
	return tmpDir
}
1364966
def tempdir():
    """"""
    directory_path = tempfile.mkdtemp()

    def clean_up():  # pylint: disable=missing-docstring
        shutil.rmtree(directory_path, onerror=on_error)

    with cd(directory_path, clean_up):
        yield directory_path
134247
def destroyTempDir(self, tempDir):
        
        #Do basic assertions for goodness of the function
        assert os.path.isdir(tempDir)
        assert os.path.commonprefix((self.rootDir, tempDir)) == self.rootDir #Checks file is part of tree
        #Update stats.
        self.tempFilesDestroyed += 1
        #Do the actual removal
        try:
            os.rmdir(tempDir)
        except OSError:
            shutil.rmtree(tempDir)
            #system("rm -rf %s" % tempDir)
        self.__destroyFile(tempDir)
85317
func LastDir(path string) (string, error) {
	absPath, err := filepath.Abs(path)
	if err != nil {
		return "", err
	}

	info, err := os.Stat(absPath)
	if err != nil {
		return "", err
	}

	var dir string
	if info.IsDir() {
		_, dir = filepath.Split(absPath)
	} else {
		dir = filepath.Dir(absPath)
		_, dir = filepath.Split(dir)
	}

	return dir, nil
}
285486
func (mounter *Mounter) MakeDir(pathname string) error {
	err := os.MkdirAll(pathname, os.FileMode(0755))
	if err != nil {
		if !os.IsExist(err) {
			return err
		}
	}
	return nil
}
402503
func CopyDir(src string, dst string) (err error) {
	src = filepath.Clean(src)
	dst = filepath.Clean(dst)

	si, err := os.Stat(src)
	if err != nil {
		return err
	}
	if !si.IsDir() {
		return errSrcNotDir
	}

	_, err = os.Stat(dst)
	if err != nil && !os.IsNotExist(err) {
		return
	}
	if err == nil {
		return errDestExist
	}

	err = os.MkdirAll(dst, si.Mode())
	if err != nil {
		return
	}

	entries, err := ioutil.ReadDir(src)
	if err != nil {
		return
	}

	for _, entry := range entries {
		srcPath := filepath.Join(src, entry.Name())
		dstPath := filepath.Join(dst, entry.Name())

		if entry.IsDir() {
			err = CopyDir(srcPath, dstPath)
			if err != nil {
				return
			}
		} else {
			// This will include symlinks, which is what we want in all cases
			// where gps is copying things.
			err = CopyFile(srcPath, dstPath)
			if err != nil {
				return
			}
		}
	}

	return
}
126895
func MakeTempDir(prefix string, mode os.FileMode) (string, error) {
	path := TempPath("", prefix)
	if err := os.MkdirAll(path, mode); err != nil {
		return "", err
	}
	return path, 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
}
947783
func GetTempDir() string {
	tempGaugeDir := filepath.Join(os.TempDir(), "gauge_temp")
	tempGaugeDir += strconv.FormatInt(time.Now().UnixNano(), 10)
	if !exists(tempGaugeDir) {
		os.MkdirAll(tempGaugeDir, NewDirectoryPermissions)
	}
	return tempGaugeDir
}
501758
func cleanupTempFiles() {
	tempFilesMu.Lock()
	for _, f := range tempFiles {
		os.Remove(f)
	}
	tempFiles = nil
	tempFilesMu.Unlock()
}
1079692
func TempFile(prefix string) (string, error) {
	tmp, err := TempFileName(prefix)
	if err != nil {
		return "", err
	}
	return filepath.Join(os.TempDir(), tmp), nil
}
1317286
func tempFd() (*os.File, error) {
	file, err := ioutil.TempFile("/dev/shm/", "journal.XXXXX")
	if err != nil {
		return nil, err
	}
	err = syscall.Unlink(file.Name())
	if err != nil {
		return nil, err
	}
	return file, nil
}
473802
func removeTempFile(dir, file string) {
	changeDir(dir)
	if err := os.Remove(file); err != nil {
		beeLogger.Log.Warnf("Could not remove temporary file: %s", err)
	}
}
1238075
func (DefaultFs) TempDir(dir, prefix string) (string, error) {
	return ioutil.TempDir(dir, prefix)
}
63903
func TempDir(prefix string) (path string, err error) {
	// Create temp file
	var f *os.File
	if f, err = ioutil.TempFile(os.TempDir(), prefix); err != nil {
		err = errors.Wrap(err, "creating temporary file failed")
		return
	}
	path = f.Name()

	// Close temp file
	if err = f.Close(); err != nil {
		err = errors.Wrapf(err, "closing file %s failed", path)
		return
	}

	// Delete temp file
	if err = os.Remove(path); err != nil {
		err = errors.Wrapf(err, "removing %s failed", path)
		return
	}

	// Create temp dir
	if err = os.MkdirAll(path, 0755); err != nil {
		err = errors.Wrapf(err, "mkdirall of %s failed", path)
		return
	}
	return
}
965180
func Envs(tempdir string) string {
	envs := path.Join(tempdir, ".envs")
	b, err := ioutil.ReadFile(envs)
	if err != nil {
		return ""
	}
	return string(b)
}
663417
func ConfigTmpDir() (string, error) {
	if tmpdir := os.Getenv("PACKER_TMP_DIR"); tmpdir != "" {
		return filepath.Abs(tmpdir)
	}
	configdir, err := packer.ConfigDir()
	if err != nil {
		return "", err
	}
	td := filepath.Join(configdir, "tmp")
	_, err = os.Stat(td)
	if os.IsNotExist(err) {
		if err = os.MkdirAll(td, 0755); err != nil {
			return "", err
		}
	} else if err != nil {
		return "", err
	}
	return td, nil
}