Deletes all items in the given path list followed by all bucket items.
503674
private void deleteInternal(List<FileInfo> itemsToDelete, List<FileInfo> bucketsToDelete)
      throws IOException {
    // TODO(user): We might need to separate out children into separate batches from parents to
    // avoid deleting a parent before somehow failing to delete a child.

    // Delete children before their parents.
    //
    // Note: we modify the input list, which is ok for current usage.
    // We should make a copy in case that changes in future.
    itemsToDelete.sort(FILE_INFO_PATH_COMPARATOR.reversed());

    if (!itemsToDelete.isEmpty()) {
      List<StorageResourceId> objectsToDelete = new ArrayList<>(itemsToDelete.size());
      for (FileInfo fileInfo : itemsToDelete) {
        // TODO(b/110833109): populate generation ID in StorageResourceId when listing infos?
        objectsToDelete.add(
            new StorageResourceId(
                fileInfo.getItemInfo().getBucketName(),
                fileInfo.getItemInfo().getObjectName(),
                fileInfo.getItemInfo().getContentGeneration()));
      }
      gcs.deleteObjects(objectsToDelete);
    }

    if (!bucketsToDelete.isEmpty()) {
      List<String> bucketNames = new ArrayList<>(bucketsToDelete.size());
      for (FileInfo bucketInfo : bucketsToDelete) {
        StorageResourceId resourceId = bucketInfo.getItemInfo().getResourceId();
        gcs.waitForBucketEmpty(resourceId.getBucketName());
        bucketNames.add(resourceId.getBucketName());
      }
      if (options.enableBucketDelete()) {
        gcs.deleteBuckets(bucketNames);
      } else {
        logger.atInfo().log(
            "Skipping deletion of buckets because enableBucketDelete is false: %s", bucketNames);
      }
    }
  }
755038
def clear_data(self):
        
        # Removes the item from filesystem and resets URL to ''
        url = self.get_url()
        # try to clear from payload first, in case that fails we won't mess with AWS
        self._payload.clear_url()
        os.remove(url)
703103
def clear(self):
        '''
        
        '''
        if os.path.exists(self.path):
            os.remove(self.path)
272077
def _remove_files(self, directory, pattern):
        '''
        
        '''
        for root, dirnames, file_names in os.walk(directory):
            for file_name in fnmatch.filter(file_names, pattern):
                os.remove(os.path.join(root, file_name))
689938
def delete_files(paths):
    
    for path in paths:
        if os.path.exists(path):
            os.remove(path)
379484
public boolean removeAll() throws IOException
  {
    if (isDirectory() && ! isLink()) {
      String []list = list();

      for (int i = 0; i < list.length; i++) {
        PathImpl subpath = lookup(list[i]);
        subpath.removeAll();
      }
    }

    return remove();
  }
82402
def clean(self, exclude, max_count=None):
        
        return self.client.remove_objects(self.bucket, itertools.islice(
            (x.object_name for x in self.client.list_objects(self.bucket, self.remote_path + '/')
             if x not in exclude), max_count))
1330216
public void deleteAll() {
        if(trackedFiles.size() == 0) {
            return;
        }

        ArrayList<File> files = new ArrayList<File>(trackedFiles);
        Collections.sort(files, filePathComparator);

        for(File file : files) {
            if(file.exists()) {
                if(!file.delete()) {
                    throw new DataUtilException("Couldn't delete a tracked "
                            + (file.isFile()? "file":"directory" + ": ") + file.getAbsolutePath());
                }
            }
        }

        trackedFiles.clear();
    }
864482
def destroy
      if attached?
        self.storage.destroy(self.path)
        self.styles.each do |style, options|
          self.storage.destroy(self.path(style))
        end
      end
      @purge = []
      @queue = {}
    end
316425
private void purgeDirectories(FileSystem fs, Path root) throws IOException {
    DirectoryTraversal traversal =
        DirectoryTraversal.directoryRetriever(Arrays.asList(root), fs,
            directoryTraversalThreads, directoryTraversalShuffle);
    String prefix = root.toUri().getPath();
    
    FileStatus dir;
    while ((dir = traversal.next()) != DirectoryTraversal.FINISH_TOKEN) {
      Path dirPath = dir.getPath();
      if (dirPath.toUri().getPath().endsWith(RaidNode.HAR_SUFFIX)) {
        continue;
      }
      String dirStr = dirPath.toUri().getPath();
      if (!dirStr.startsWith(prefix)) {
        continue;
      }
      entriesProcessed.incrementAndGet();
      String src = dirStr.replaceFirst(prefix, "");
      if (src.length() == 0) continue;
      Path srcPath = new Path(src);
      if (!fs.exists(srcPath)) {
        performDelete(fs, dirPath, true);
      }
    }
  }
292376
private static void deleteIfExists(Path path) throws IOException {
		FileSystem fs = path.getFileSystem();
		if (fs.exists(path)) {
			fs.delete(path, true);
		}
	}
1102417
def purge(path: str, pattern: str) -> None:
    
    for f in find(pattern, path):
        log.info("Deleting {}", f)
        os.remove(f)
869009
private void cleanupLists(PrefixKey key) {
    // Remove expired list entries. Keep track of the last list removed.
    NavigableMap<PrefixKey, CacheValue<Object>> head = prefixMap.headMap(key, true).descendingMap();
    Iterator<Entry<PrefixKey, CacheValue<Object>>> headItr = head.entrySet().iterator();
    Entry<PrefixKey, CacheValue<Object>> last = null;

    while (headItr.hasNext()) {
      Entry<PrefixKey, CacheValue<Object>> entry = headItr.next();
      if (isExpired(entry.getValue()) && key.isParent(entry.getKey())) {
        last = entry;
        headItr.remove();
      }
    }

    // If a list was removed, check its contained items for expiration.
    if (last != null) {
      SortedMap<PrefixKey, CacheValue<GoogleCloudStorageItemInfo>> prefix =
          getPrefixSubMap(itemMap, last.getKey());
      prefix.entrySet().removeIf(entry -> isExpired(entry.getValue()));
    }
  }
311487
def delete_all_thumbnails(path, recursive=True):
    
    total = 0
    for thumbs in all_thumbnails(path, recursive=recursive).values():
        total += _delete_using_thumbs_list(thumbs)
    return total
1016552
private void deleteBackups() {
        File[] storeDirList = ReadOnlyUtils.getVersionDirs(storeDir, 0L, getCurrentVersionId());
        if(storeDirList != null && storeDirList.length > (numBackups + 1)) {
            // delete ALL old directories asynchronously
            File[] extraBackups = ReadOnlyUtils.findKthVersionedDir(storeDirList,
                                                                    0,
                                                                    storeDirList.length
                                                                            - (numBackups + 1) - 1);
            if(extraBackups != null) {
                for(File backUpFile: extraBackups) {
                    deleteAsync(backUpFile);
                }
            }
        }
    }
1122024
public void clear() {
    // Clears all keys, values and buckets linked lists.
    for (EntryImpl<K, V> entry = _mapFirst; entry != null; entry = entry._after) {
      entry._key = null;
      entry._value = null;
      entry._before = null;
      entry._next = null;
      if (entry._previous == null) { // First in bucket.
        _entries[entry._index] = null;
      } else {
        entry._previous = null;
      }
    }

    // Recycles all entries.
    if (_mapLast != null) {
      _mapLast._after = _poolFirst; // Connects to pool.
      _poolFirst = _mapFirst;
      _mapFirst = null;
      _mapLast = null;
      _size = 0;
      sizeChanged();
    }
  }
238167
private void removeEsDirectoryRecursively(final String path) throws Exception {
        logger.debug("Delete folder [{}]", path);
        Collection<String> listFile = getFileDirectory(path);

        for (String esfile : listFile) {
            esDelete(fsSettings.getElasticsearch().getIndex(), SignTool.sign(path.concat(File.separator).concat(esfile)));
        }

        Collection<String> listFolder = getFolderDirectory(path);
        for (String esfolder : listFolder) {
            removeEsDirectoryRecursively(esfolder);
        }

        esDelete(fsSettings.getElasticsearch().getIndexFolder(), SignTool.sign(path));
    }