Like :meth:`removedirs`, but does not raise an exception if the
        directory is not empty or does not exist.
765344
def removedirs_p(self):
        
        with contextlib.suppress(FileExistsError, DirectoryNotEmpty):
            with DirectoryNotEmpty.translate():
                self.removedirs()
        return self
272660
function ensureExistsAndClean (dir) {
  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir)
  } else {
    cleanDir(dir)
  }
}
937592
def removedirs_p(self):
        
        try:
            self.removedirs()
        except OSError:
            _, e, _ = sys.exc_info()
            if e.errno != errno.ENOTEMPTY and e.errno != errno.EEXIST:
                raise
        return self
961902
def ensure_exists(self):
        """"""
        if not self.context.is_directory(self.directory):
            # This can also happen when we don't have permission to one of the
            # parent directories so we'll point that out in the error message
            # when it seems applicable (so as not to confuse users).
            if self.context.have_superuser_privileges:
                msg = "The directory %s doesn't exist!"
                raise ValueError(msg % self)
            else:
                raise ValueError(compact("""
                    The directory {location} isn't accessible, most likely
                    because it doesn't exist or because of permissions. If
                    you're sure the directory exists you can use the
                    --use-sudo option.
                """, location=self))
138974
def remove_folder_content(path, ignore_hidden_file=False):
    
    for file in os.listdir(path):
        if ignore_hidden_file and file.startswith('.'):
            continue

        file_path = os.path.join(path, file)
        if os.path.isdir(file_path):
            shutil.rmtree(file_path)
        else:
            os.remove(file_path)
961307
@Nonnull
  public static FileIOError deleteDir (@Nonnull final Path aDir)
  {
    ValueEnforcer.notNull (aDir, "Directory");

    final Path aRealDir = _getUnifiedPath (aDir);

    // Does the directory not exist?
    if (!aRealDir.toFile ().isDirectory ())
      return EFileIOErrorCode.SOURCE_DOES_NOT_EXIST.getAsIOError (EFileIOOperation.DELETE_DIR, aRealDir);

    if (isExceptionOnDeleteRoot ())
    {
      // Check that we're not deleting the complete hard drive...
      if (aRealDir.getParent () == null || aRealDir.getNameCount () == 0)
        throw new IllegalArgumentException ("Aren't we deleting the full drive: '" + aRealDir + "'");
    }

    // Is the parent directory writable?
    final Path aParentDir = aRealDir.getParent ();
    if (aParentDir != null && !Files.isWritable (aParentDir))
      return EFileIOErrorCode.SOURCE_PARENT_NOT_WRITABLE.getAsIOError (EFileIOOperation.DELETE_DIR, aRealDir);

    return _perform (EFileIOOperation.DELETE_DIR, Files::delete, aRealDir);
  }
853459
def directoryRemove(self, dir_key, key):
    '''
    '''
    key = str(key)

    dir_items = self.get(dir_key) or []
    if key in dir_items:
      dir_items = [k for k in dir_items if k != key]
      self.put(dir_key, dir_items)
998675
def reset_directory(directory):
    
    if os.path.isdir(directory): shutil.rmtree(directory)
    if not os.path.isdir(directory): os.makedirs(directory)
615666
def remove_blank_dirs(self):
        """"""
        if self.is_blank():
            try:
                os.rmdir(self.path)
            except OSError as e:
                print(e)
        else:
            remove_empty_dir(self.path)
659258
def rm(path, isdir=False):
    
    if isdir:
        deleted = os.path.isdir(path)
        shutil.rmtree(path, ignore_errors=True)
    elif os.path.isfile(path) or os.path.islink(path):
        deleted = True
        os.remove(path)
    else:
        deleted = False
    return deleted
490117
def remove_on_exception(dirname, remove=True):
    """"""
    os.makedirs(dirname)
    try:
        yield
    except:
        if remove:
            shutil.rmtree(dirname, ignore_errors=True)
        raise
1289093
def clean(cls, path):
        ''''''
        for pth in os.listdir(path):
            pth = os.path.abspath(os.path.join(path, pth))
            if os.path.isdir(pth):
                logger.debug('Removing directory %s' % pth)
                shutil.rmtree(pth)
            else:
                logger.debug('Removing file %s' % pth)
                os.remove(pth)
302378
def remove_directory(self, directory_name, *args, **kwargs):
		
		previous_path = self.session_path()
		try:
			self.session_path(directory_name)
			os.rmdir(self.full_path())
		finally:
			self.session_path(previous_path)
757733
def rmtree(directory: str) -> None:
    
    log.debug("Deleting directory {!r}", directory)
    shutil.rmtree(directory, onerror=shutil_rmtree_onerror)
1297258
def rmrf(items, verbose=True):
    ""
    if isinstance(items, str):
        items = [items]

    for item in items:
        if verbose:
            print("Removing {}".format(item))
        shutil.rmtree(item, ignore_errors=True)
        # rmtree doesn't remove bare files
        try:
            os.remove(item)
        except FileNotFoundError:
            pass
1159193
public function clean($folder, $removeDirectory = false)
    {
        if ( ! is_dir($folder)) {
            throw new \Exception(('Not a folder.'));
        }

        array_map('unlink', glob($folder . DIRECTORY_SEPARATOR . '*'));
        if ($removeDirectory && file_exists($folder)) {
            rmdir($folder);
        }
    }
14024
def clear(self):
        
        not_removed = []
        for fn in os.listdir(self.base):
            fn = os.path.join(self.base, fn)
            try:
                if os.path.islink(fn) or os.path.isfile(fn):
                    os.remove(fn)
                elif os.path.isdir(fn):
                    shutil.rmtree(fn)
            except Exception:
                not_removed.append(fn)
        return not_removed