Deletes all cache files corresponding to a list of hashes from a directory

    :param str directory: The type of cache to delete files for.
    :param list(str) hashes: The hashes to delete the files for
493593
def delete_from_directory_by_hashes(cache_type, hashes):
    
    global CACHE_
    if hashes == '*':
        CACHE_[cache_type] = {}
    for h in hashes:
        if h in CACHE_[cache_type]:
            del CACHE_[cache_type][h]
    write_out()
1210981
private void deleteExecutorDirs(String[] dirs) {
    for (String localDir : dirs) {
      try {
        JavaUtils.deleteRecursively(new File(localDir));
        logger.debug("Successfully cleaned up directory: {}", localDir);
      } catch (Exception e) {
        logger.error("Failed to delete directory: " + localDir, e);
      }
    }
  }
173970
public static boolean deleteDir(File dir) {
		if (dir != null && dir.isDirectory()) {
			String[] children = dir.list();
			for (int i = 0; i < children.length; i++) {
				if (!deleteDir(new File(dir, children[i])))
					return false;
			}
		}
		return dir.delete();
	}
421491
def list_dirs(directory):
    
    return [f for f in pathlib.Path(directory).iterdir() if f.is_dir()]
523579
public void clearCache() {
        File cacheDir = getCacheDir();
        if (cacheDir.exists()) {
            File[] files = cacheDir.listFiles();
            if (files != null) {
                for (File child : files) {
                    deleteFilesRecursively(child);
                }
            }
        }
    }
1175216
def clear_file_list_cache(self, load):
        '''
        
        '''
        if 'env' in load:
            # "env" is not supported; Use "saltenv".
            load.pop('env')

        saltenv = load.get('saltenv', [])
        if saltenv is not None:
            if not isinstance(saltenv, list):
                try:
                    saltenv = [x.strip() for x in saltenv.split(',')]
                except AttributeError:
                    saltenv = [x.strip() for x in six.text_type(saltenv).split(',')]

            for idx, val in enumerate(saltenv):
                if not isinstance(val, six.string_types):
                    saltenv[idx] = six.text_type(val)

        ret = {}
        fsb = self.backends(load.pop('fsbackend', None))
        list_cachedir = os.path.join(self.opts['cachedir'], 'file_lists')
        try:
            file_list_backends = os.listdir(list_cachedir)
        except OSError as exc:
            if exc.errno == errno.ENOENT:
                log.debug('No file list caches found')
                return {}
            else:
                log.error(
                    'Failed to get list of saltenvs for which the master has '
                    'cached file lists: %s', exc
                )

        for back in file_list_backends:
            # Account for the fact that the file_list cache directory for gitfs
            # is 'git', hgfs is 'hg', etc.
            back_virtualname = re.sub('fs$', '', back)
            try:
                cache_files = os.listdir(os.path.join(list_cachedir, back))
            except OSError as exc:
                log.error(
                    'Failed to find file list caches for saltenv \'%s\': %s',
                    back, exc
                )
                continue
            for cache_file in cache_files:
                try:
                    cache_saltenv, extension = cache_file.rsplit('.', 1)
                except ValueError:
                    # Filename has no dot in it. Not a cache file, ignore.
                    continue
                if extension != 'p':
                    # Filename does not end in ".p". Not a cache file, ignore.
                    continue
                elif back_virtualname not in fsb or \
                        (saltenv is not None and cache_saltenv not in saltenv):
                    log.debug(
                        'Skipping %s file list cache for saltenv \'%s\'',
                        back, cache_saltenv
                    )
                    continue
                try:
                    os.remove(os.path.join(list_cachedir, back, cache_file))
                except OSError as exc:
                    if exc.errno != errno.ENOENT:
                        log.error('Failed to remove %s: %s',
                                  exc.filename, exc.strerror)
                else:
                    ret.setdefault(back, []).append(cache_saltenv)
                    log.debug(
                        'Removed %s file list cache for saltenv \'%s\'',
                        cache_saltenv, back
                    )
        return ret
1256915
def _delete_dir(dir):
    
    try:
        shutil.rmtree(dir)  # delete directory
    except OSError as exc:
        if exc.errno != 2:  # code 2 - no such file or directory
            raise  # re-raise exception
    except UnboundLocalError:
        pass
733023
def cachedir_index_del(minion_id, base=None):
    '''
    
    '''
    base = init_cachedir(base)
    index_file = os.path.join(base, 'index.p')
    lock_file(index_file)

    if os.path.exists(index_file):
        mode = 'rb' if six.PY3 else 'r'
        with salt.utils.files.fopen(index_file, mode) as fh_:
            index = salt.utils.data.decode(
                salt.utils.msgpack.load(fh_, encoding=MSGPACK_ENCODING))
    else:
        return

    if minion_id in index:
        del index[minion_id]

    mode = 'wb' if six.PY3 else 'w'
    with salt.utils.files.fopen(index_file, mode) as fh_:
        salt.utils.msgpack.dump(index, fh_, encoding=MSGPACK_ENCODING)

    unlock_file(index_file)
1038676
def flush(key):
    
    flush_list = []
    for item in cache:
        if key in item:
            flush_list.append(item)
    for item in flush_list:
        del cache[item]
1048298
public static boolean clearDirectory(File directory) {
		Assert.isTrue(directory.isDirectory(), "Parameter ist kein Verzeichnis");
		File[] files = directory.listFiles();
		boolean allDeleted = true;
		for (File file : files) {
			if (file.isDirectory()) {
				clearDirectory(file);
			}
			allDeleted &= file.delete();
		}

		return allDeleted;
	}
1126455
def _remove_blacklisted(self, directories):
        
        directories = util.to_absolute_paths(directories)
        directories = util.remove_from_set(directories,
                                           self.blacklisted_directories)

        return directories
852083
def pycache_clean(context):
    ""
    #pylint: disable=unused-argument
    dirs = set()
    for root, dirnames, _ in os.walk(os.curdir):
        if '__pycache__' in dirnames:
            dirs.add(os.path.join(root, '__pycache__'))
    print("Removing __pycache__ directories")
    rmrf(dirs, verbose=False)
755661
def _clear_dir(dirName):
    
    # If we got here, clear dir  
    for fname in os.listdir(dirName):
        try:
            os.remove( os.path.join(dirName, fname) )
        except Exception:
            pass
    try:
        os.rmdir(dirName)
    except Exception:
        pass
53473
def listdir(directory):
    
    file_names = list()
    for filename in os.listdir(directory):
        file_path = os.path.join(directory, filename)
        if os.path.isdir(file_path):
            filename = f'{filename}{os.path.sep}'
        file_names.append(filename)
    return file_names
382493
def delete_by_hash(self, file_hash):
        
        full_path = self.file_path_from_hash(file_hash)

        return self.delete_by_path(full_path)
802379
def clear_caches(delete_all=False):
    
    global _time_caches

    if delete_all:
        _time_caches = []
        _parser = { "default": CodeParser() }
    else:
        # normally just kill the expired entries, not all
        for tc in _time_caches:
            # check time_cache for expired entries
            for key, (t, value) in list(tc.items()):
                if t < time.time():
                    # delete expired entries
                    del tc[key]
332094
function(startDir) {
					var i, j, empty, stat;
					for (i in cache) {
						empty = true;
						if (i.indexOf(options.baseUrl) > -1) {
							this.deleteFile(i);
							continue;
						}

						stat = cache[i].stat;

						if (stat.isDirectory()) {
							for (j in cache) {
								if (j.indexOf(i) > -1) {
									empty = false;
									break;
								}
							}

							if (empty) {
								this.deleteFile(i);
							}
						}
					}
				}