// AddEmptyDir adds a raw directory entry to TzArchive,
// it returns false if same directory enry already existed.
510285
func (tz *TzArchive) AddEmptyDir(dirPath string) bool {
	if !strings.HasSuffix(dirPath, "/") {
		dirPath += "/"
	}

	for _, f := range tz.files {
		if dirPath == f.Name {
			return false
		}
	}

	dirPath = strings.TrimSuffix(dirPath, "/")
	if strings.Contains(dirPath, "/") {
		// Auto add all upper level directories.
		tz.AddEmptyDir(path.Dir(dirPath))
	}
	tz.files = append(tz.files, &File{
		Header: &tar.Header{
			Name: dirPath + "/",
		},
	})
	tz.updateStat()
	return true
}
1066333
func (c *Context) NewTempDir(prefix string) (string, error) {
	t, err := ioutil.TempDir(c.Tmpdir, prefix)
	if err != nil {
		return "", fmt.Errorf("error creating temporary directory: %v", err)
	}
	return t, nil
}
611658
func ImgBuildDir(path string) option {
	return func(c *sass) error {
		c.ctx.GenImgDir = path
		return nil
	}
}
178966
func tarGzDir(srcDirPath string, recPath string, tw *tar.Writer) error {
	// Open source diretory
	dir, err := os.Open(srcDirPath)
	if err != nil {
		return err
	}
	defer dir.Close()

	// Get file info slice
	fis, err := dir.Readdir(0)
	if err != nil {
		return err
	}
	for _, fi := range fis {
		// Append path
		curPath := srcDirPath + "/" + fi.Name()
		// Check it is directory or file
		if fi.IsDir() {
			// Directory
			// (Directory won't add unitl all subfiles are added)
			fmt.Printf("Adding path...%s\n", curPath)
			tarGzDir(curPath, recPath+"/"+fi.Name(), tw)
		} else {
			// File
			fmt.Printf("Adding file...%s\n", curPath)
		}

		tarGzFile(curPath, recPath+"/"+fi.Name(), tw, fi)
	}
	return err
}
633629
func pathEmpty(path string) (bool, error) {
	f, err := os.Open(path)
	if err != nil {
		return false, err
	}
	defer f.Close()
	entries, err := f.Readdir(1)
	if err != nil && err != io.EOF {
		return false, err
	}
	return len(entries) == 0, nil
}
212962
func newTempFile(dir, prefix, suffix string) (*os.File, error) {
	for index := 1; index < 10000; index++ {
		path := filepath.Join(dir, fmt.Sprintf("%s%03d%s", prefix, index, suffix))
		if _, err := os.Stat(path); err != nil {
			return os.Create(path)
		}
	}
	// Give up
	return nil, fmt.Errorf("could not create file of the form %s%03d%s", prefix, 1, suffix)
}
902061
func TmpDir(t TestReporter, dir string) string {
	name, err := afero.TempDir(appFs, dir, "dir")
	if err != nil {
		t.Error("Failed to create the tmpDir: "+name, err)
	}

	Files = append(Files, name)
	return name
}
1008505
func allEmpty(pl map[string]interface{}) bool {
	for _, v := range pl {
		vStr, ok := v.(string)
		if !ok {
			// wouldn't coerce to string, so it must have something that's not an
			// empty string
			return false
		}
		if vStr != "" {
			return false
		}
	}
	// we've gone through the entire map and every field value has matched ""
	return true
}
918833
func (r *Row) IsEmpty() bool {
	if len(r.segments) == 0 {
		return true
	}
	for i := range r.segments {
		if r.segments[i].n > 0 {
			return false
		}

	}
	return true
}
109107
func (c *ChannelAuthProof) IsEmpty() bool {
	return len(c.NodeSig1Bytes) == 0 ||
		len(c.NodeSig2Bytes) == 0 ||
		len(c.BitcoinSig1Bytes) == 0 ||
		len(c.BitcoinSig2Bytes) == 0
}
944962
func isEmpty(f *os.File) (bool, error) {
	fi, err := f.Stat()
	if err != nil {
		return false, trace.Wrap(err)
	}

	if fi.Size() > 0 {
		return false, nil
	}

	return true, nil
}
741810
func (v mergeStrategy) MergeEmpty(diff apply.EmptyElement) (apply.Result, error) {
	return apply.Result{Operation: apply.SET}, nil
}
1351458
func (id FlexID) IsEmpty() bool {
	if id.ID() == "" {
		// Just checking the ID portion should be sufficient
		// This will allow for Empty Domains, and Classes, though they would still
		//  be invalid, this is not designed to check validity
		return true
	}
	// We also need to check if it's a Manifold ID because it will have a ID
	//  consisting of 0s, and not be empty string
	if id.Domain() == ManifoldDomain {
		mid, err := id.AsManifoldID()
		if err == nil {
			return mid.IsEmpty()
		}
	}
	return false
}
462917
func AddStderr(name, stdout, stderr string) (string, error) {
	return add(name, stdout, stderr, 0)
}
631658
func newVirtualDir(ed *embedded.EmbeddedDir) *virtualDir {
	vd := &virtualDir{
		EmbeddedDir: ed,
		offset:      0,
		closed:      false,
	}
	return vd
}
506283
func (u *FakeVolumeUtil) AddNewDirEntries(mountDir string, dirFiles map[string][]*FakeDirEntry) {
	for dir, files := range dirFiles {
		mountedPath := filepath.Join(mountDir, dir)
		curFiles := u.directoryFiles[mountedPath]
		if curFiles == nil {
			curFiles = []*FakeDirEntry{}
		}
		glog.Infof("Adding to directory %q: files %v\n", dir, files)
		u.directoryFiles[mountedPath] = append(curFiles, files...)
	}
}
831041
func (z *Zip) AddDir(root, target string) error {
	return filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}

		if !info.Mode().IsRegular() {
			return nil
		}

		file, err := os.Open(path)
		if err != nil {
			return err
		}
		defer file.Close()

		rel, err := filepath.Rel(root, path)
		if err != nil {
			return err
		}

		archivePath := filepath.Join(target, rel)
		return z.AddFile(archivePath, file)
	})
}