// RecursiveDelete deletes the given entry from the given filesystem.
// If it's a directory, first all the items in the directory are
// deleted recursively.
179012
func RecursiveDelete(
	ctx context.Context, fs billy.Filesystem, fi os.FileInfo) error {
	select {
	case <-ctx.Done():
		return ctx.Err()
	default:
	}

	if !fi.IsDir() {
		// Delete regular files and symlinks directly.
		return fs.Remove(fi.Name())
	}

	subdirFS, err := fs.Chroot(fi.Name())
	if err != nil {
		return err
	}

	children, err := subdirFS.ReadDir("/")
	if err != nil {
		return err
	}
	for _, childFI := range children {
		if childFI.Name() == "." {
			continue
		}
		err := RecursiveDelete(ctx, subdirFS, childFI)
		if err != nil {
			return err
		}
	}

	return fs.Remove(fi.Name())
}
1104049
func (ln *LocalNode) Delete(e enr.Entry) {
	ln.mu.Lock()
	defer ln.mu.Unlock()

	ln.delete(e)
}
211956
func (t *LLRB) Delete(key Item) Item {
	var deleted Item
	t.root, deleted = t.delete(t.root, key)
	if t.root != nil {
		t.root.Black = true
	}
	if deleted != nil {
		t.count--
	}
	return deleted
}
126025
func (s *memcachedStorage) Delete(key string) error {
	return s.c.Delete(key)
}
732332
func (c *Files) PermanentlyDelete(in *PermanentlyDeleteInput) (err error) {
	body, err := c.call("/files/delete", in)
	if err != nil {
		return
	}
	defer body.Close()

	return
}
1173943
func (m *dirsMap) Delete(key string) {
	m.data.Delete(m.normalizeKey(key))
}
989162
func (s *Store) Delete(ctx context.Context, name string) error {
	path := filepath.Join(s.path, filepath.Clean(name))
	out.Debug(ctx, "fs.Delete(%s) - %s", name, path)

	if err := os.Remove(path); err != nil {
		return err
	}

	return s.removeEmptyParentDirectories(path)
}
1287350
func (s Byte) Delete(items ...byte) {
	for _, item := range items {
		delete(s, item)
	}
}
388153
func (m *MemDB) Delete(key []byte, o *db.WriteOptions) error {
	m.mutex.Lock()
	defer m.mutex.Unlock()
	n, exactMatch := m.findNode(key, nil)
	if !exactMatch || m.nodeData[n+fVal] == kvOffsetDeletedNode {
		return db.ErrNotFound
	}
	m.nodeData[n+fVal] = kvOffsetDeletedNode
	return nil
}
506686
func (e *EtcdStore) Delete(key string, recurse bool) error {
	c, q := context.WithTimeout(context.Background(), e.Timeout)
	defer q()

	o := &client.DeleteOptions{Recursive: recurse}
	return del(e, c, o, key)
}
966295
func Delete(path string, h interface{}, m ...interface{}) {
	Default.Delete(path, h, m...)
}
1189987
func (d *Failstore) Delete(k ds.Key) error {
	err := d.errfunc("delete")
	if err != nil {
		return err
	}

	return d.child.Delete(k)
}
989651
func (t *Trie) TryDelete(key []byte) error {
	k := keybytesToHex(key)
	_, n, err := t.delete(t.root, nil, k)
	if err != nil {
		return err
	}
	t.root = n
	return nil
}
800568
func (t *Collection) Delete(key []byte) (wasDeleted bool, err error) {
	if t.store.readOnly {
		return false, errors.New("store is read only")
	}
	rnl := t.rootAddRef()
	defer t.rootDecRef(rnl)
	root := rnl.root
	i, err := t.GetItem(key, false)
	if err != nil || i == nil {
		return false, err
	}
	t.store.ItemDecRef(t, i)
	left, middle, right, err := t.store.split(t, root, key, &rnl.reclaimMark)
	if err != nil {
		return false, err
	}
	defer t.freeNodeLoc(left)
	defer t.freeNodeLoc(right)
	defer t.freeNodeLoc(middle)
	if middle.isEmpty() {
		return false, fmt.Errorf("concurrent delete, key: %v", key)
	}
	r, err := t.store.join(t, left, right, &rnl.reclaimMark)
	if err != nil {
		return false, err
	}
	rnlNew := t.mkRootNodeLoc(r)
	// Can't reclaim immediately due to readers.
	rnlNew.reclaimLater[0] = t.reclaimMarkUpdate(left,
		&rnl.reclaimMark, &rnlNew.reclaimMark)
	rnlNew.reclaimLater[1] = t.reclaimMarkUpdate(right,
		&rnl.reclaimMark, &rnlNew.reclaimMark)
	rnlNew.reclaimLater[2] = t.reclaimMarkUpdate(middle,
		&rnl.reclaimMark, &rnlNew.reclaimMark)
	t.markReclaimable(rnlNew.reclaimLater[2], &rnlNew.reclaimMark)
	if !t.rootCAS(rnl, rnlNew) {
		return false, errors.New("concurrent mutation attempted")
	}
	t.rootDecRef(rnl)
	return true, nil
}
531217
func cleanupDir(ctx context.Context, storage StorageAPI, volume, dirPath string) error {
	var delFunc func(string) error
	// Function to delete entries recursively.
	delFunc = func(entryPath string) error {
		if !hasSuffix(entryPath, slashSeparator) {
			// Delete the file entry.
			err := storage.DeleteFile(volume, entryPath)
			logger.LogIf(ctx, err)
			return err
		}

		// If it's a directory, list and call delFunc() for each entry.
		entries, err := storage.ListDir(volume, entryPath, -1, "")
		// If entryPath prefix never existed, safe to ignore.
		if err == errFileNotFound {
			return nil
		} else if err != nil { // For any other errors fail.
			logger.LogIf(ctx, err)
			return err
		} // else on success..

		// Entry path is empty, just delete it.
		if len(entries) == 0 {
			err = storage.DeleteFile(volume, path.Clean(entryPath))
			logger.LogIf(ctx, err)
			return err
		}

		// Recurse and delete all other entries.
		for _, entry := range entries {
			if err = delFunc(pathJoin(entryPath, entry)); err != nil {
				return err
			}
		}
		return nil
	}
	err := delFunc(retainSlash(pathJoin(dirPath)))
	return err
}
695591
func (s String) Delete(items ...string) {
	for _, item := range items {
		delete(s, item)
	}
}
551375
func (ptree *ptree) Delete(keys ...common.Comparator) {
	ra := newRemoveAction(keys)
	ptree.checkAndRun(ra)
	ra.completer.Wait()
}