// AddAll adds all files from dir in archive
// Tar does not support directories
762336
func (t *TarFile) AddAll(dir string, includeCurrentFolder bool) error {
	dir = path.Clean(dir)
	return addAll(dir, dir, includeCurrentFolder, func(info os.FileInfo, file io.Reader, entryName string) (err error) {
		// Create a header based off of the fileinfo
		header, err := tar.FileInfoHeader(info, "")
		if err != nil {
			return err
		}

		// Set the header's name to what we want--it may not include the top folder
		header.Name = entryName

		// Write the header into the tar file
		if err := t.Writer.WriteHeader(header); err != nil {
			return err
		}

		// The directory don't need copy file
		if file == nil {
			return nil
		}

		// Pipe the file into the tar
		if _, err := io.Copy(t.Writer, file); err != nil {
			return err
		}

		return nil
	})
}
906223
func (sb *storageBackend) AllFilesystems() ([]Filesystem, error) {
	filesystems, err := sb.filesystems(nil)
	if err != nil {
		return nil, errors.Annotate(err, "cannot get filesystems")
	}
	return filesystemsToInterfaces(filesystems), nil
}
1139615
func (self *Boxfile) AddStorageNode() {
  for _, node := range self.Nodes() {
    name := regexp.MustCompile(`\d+`).ReplaceAllString(node, "")
    if (name == "web" || name == "worker") && self.Node(node).Value("network_dirs") != nil {
      found := false
      for _, storage := range self.Node(node).Node("network_dirs").Nodes() {
        found = true
        if !self.Node(storage).Valid {
          self.Parsed[storage] = map[string]interface{}{"found": true}
        }
      }

      // if i dont find anything but they did have a network_dirs.. just try adding a new one
      if !found {
        if !self.Node("nfs1").Valid {
          self.Parsed["nfs1"] = map[string]interface{}{"found": true}
        }
      }
    }
  }
}
1224774
func AllPaths(dir string) (map[string]bool, error) {
	m := make(map[string]bool)
	return m, allPaths(m, nil, dir)
}
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...)
	}
}
953019
func (s *Store) allFiles() (map[string]interface{}, int) {
	files := make(map[string]interface{})

	s.m.Lock()
	for filename, ref := range s.fileRefMap {
		if ref != nil {
			files[filename] =
				map[string]interface{}{"ref_count": ref.FetchRefCount()}
		}
	}
	s.m.Unlock()

	numFilesOpen := len(files)

	fd, err := os.Open(s.dir)
	if err == nil {
		filelist, err := fd.Readdir(-1)
		fd.Close()
		if err == nil {
			for _, finfo := range filelist {
				fileEntry := map[string]interface{}{"ref_count": nil,
					"file_size":     finfo.Size(),
					"file_mode":     finfo.Mode(),
					"file_modified": finfo.ModTime(),
					"is_dir":        finfo.IsDir()}

				referencedEntry, exists := files[finfo.Name()]
				if exists {
					refMap, _ := referencedEntry.(map[string]interface{})
					fileEntry["ref_count"] = refMap["ref_count"]
				}

				files[finfo.Name()] = fileEntry
			}
		}
	}

	return files, numFilesOpen
}
1260145
func (watcher *RecursiveWatcher) addDirectory(dir string) {
	err := watcher.WatchFlags(dir, fsnotify.FSN_ALL)
	if err != nil {
		log.Println("Error watching directory: ", dir, err)
	}
}
169043
func (d *dir) add(n node) {
	if d.children == nil {
		d.children = make(map[string]node)
	}

	d.children[n.name()] = n
	d.mod = time.Now()
}
549615
func (b *PersonJSONBuilder) AddAll() *PersonJSONBuilder {
	b._properties["Name"] = b.Name
	b._properties["Age"] = b.Age
	b._properties["Password"] = b.Password
	return b
}
493205
func (c *Config) LoadAll() (bool, error) {
	c.lock.Lock()
	defer c.lock.Unlock()

	return c.MergeLoaders(c.loaders...)
}
1161441
func (ctxt *Context) AddDirectory(path string) (*types.Package, error) {
	return ctxt.builder.AddDirectoryTo(path, &ctxt.Universe)
}
322082
func statAllDirs(ctx context.Context, storageDisks []StorageAPI, bucket, prefix string) []error {
	var errs = make([]error, len(storageDisks))
	var wg sync.WaitGroup
	for index, disk := range storageDisks {
		if disk == nil {
			continue
		}
		wg.Add(1)
		go func(index int, disk StorageAPI) {
			defer wg.Done()
			entries, err := disk.ListDir(bucket, prefix, 1, "")
			if err != nil {
				errs[index] = err
				return
			}
			if len(entries) > 0 {
				errs[index] = errVolumeNotEmpty
				return
			}
		}(index, disk)
	}

	wg.Wait()
	return errs
}
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)
	})
}
25936
func (b *SampleJSONBuilder) AddAll() *SampleJSONBuilder {
	b._properties["A"] = b.A
	b._properties["B"] = b.B
	b._properties["C"] = b.C
	b._properties["D"] = b.D
	b._properties["E"] = b.E
	b._properties["F"] = b.F
	b._properties["G"] = b.G
	return b
}
720737
func (s *SourcesStore) All(ctx context.Context) ([]chronograf.Source, error) {
	return s.AllF(ctx)
}
636918
func (f *Folder) addFile(path []string, contentType string) error {
	if len(path) < 1 {
		return errors.Errorf("Path must not be empty")
	}
	name := path[0]
	if len(path) == 1 {
		if _, found := f.Files[name]; found {
			return errors.Errorf("File %s exists", name)
		}
		f.Files[name] = &File{
			Name: name,
			Metadata: map[string]string{
				"Content-Type": contentType,
			},
		}
		return nil
	}
	next := f.getFolder(name)
	return next.addFile(path[1:], contentType)
}
1223622
func (d *Dir) Add(name string, entry Entry) error {
	// TODO: Binary search
	for ii, v := range d.EntryNames {
		if v > name {
			names := make([]string, len(d.EntryNames)+1)
			copy(names, d.EntryNames[:ii])
			names[ii] = name
			copy(names[ii+1:], d.EntryNames[ii:])
			d.EntryNames = names

			entries := make([]Entry, len(d.Entries)+1)
			copy(entries, d.Entries[:ii])
			entries[ii] = entry
			copy(entries[ii+1:], d.Entries[ii:])

			d.Entries = entries
			return nil
		}
		if v == name {
			return os.ErrExist
		}
	}
	// Not added yet, put at the end
	d.EntryNames = append(d.EntryNames, name)
	d.Entries = append(d.Entries, entry)
	return nil
}