Remove file filename from path.

    :param filename: Name of file to remove
    :param path: Path where file is located
    :return: True if successfull
    :raises OSError if chdir or remove fails.
192837
def remove_file(filename, path=None):
    
    cwd = os.getcwd()
    try:
        if path:
            os.chdir(path)
    except OSError:
        raise
    try:
        os.remove(filename)
        os.chdir(cwd)
        return True
    except OSError:
        os.chdir(cwd)
        raise
96067
def move_file_to_directory(file_path, directory_path):
        
        file_name = os.path.basename(file_path)  # get name of file
        if not os.path.exists(directory_path):
            os.makedirs(directory_path)  # create directory if necessary
        os.rename(file_path, os.path.join(directory_path,
                                          file_name))
793416
def delete_dir_rec(path: Path):
    
    if not path.exists() or not path.is_dir():
        return
    for sub in path.iterdir():
        if sub.is_dir():
            delete_dir_rec(sub)
        else:
            sub.unlink()
    path.rmdir()
409540
protected void removeFile(String subdir, String filename) throws IOException {
        Path dir = root;
        if (subdir != null) {
            dir = dir.resolve(subdir);
        }
        Files.deleteIfExists(dir.resolve(filename));
    }
964059
def remove_file(filename)
      return if @sandbox

      file_path = File.join(Configuration.instance.get(:path), filename)
      File.delete(file_path) if File.exist?(file_path)
    end
1252877
def delete(self, path):
        
        mountpoint, chunks = self.get_mountpoint(path)
        apath = self._join_chunks(chunks)

        if mountpoint is None:
            try:
                simfile = self._files.pop(apath)
            except KeyError:
                return False
            else:
                self.state.history.add_event('fs_unlink', path=apath, unlink_idx=len(self.unlinks))
                self.unlinks.append((apath, simfile))
                return True
        else:
            return mountpoint.delete(chunks)
932885
def _remove_files(files):
    
    logger.debug("Request for file removal (_remove_files()).")

    for fn in files:
        if os.path.exists(fn):
            logger.debug("Removing '%s'." % fn)
            os.remove(fn)
1075498
def delete(filepath):
    
    # Some files have ACLs, let's remove them recursively
    remove_acl(filepath)

    # Some files have immutable attributes, let's remove them recursively
    remove_immutable_attribute(filepath)

    # Finally remove the files and folders
    if os.path.isfile(filepath) or os.path.islink(filepath):
        os.remove(filepath)
    elif os.path.isdir(filepath):
        shutil.rmtree(filepath)
580402
def _get_filename(self, path):
        
        match = re.search("[a-z]{2,3}_[A-Z]{2}", path)

        if match:
            start = match.start(0)
            filename = path[start:]
        else:
            filename = os.path.basename(path)

        return filename
930372
def remove_if_exist(path):  # pragma: no cover
    """"""
    if os.path.exists(path):
        if os.path.isdir(path):
            shutil.rmtree(path)
            return True
        elif os.path.isfile(path):
            os.remove(path)
            return True
    return False
497246
def safe_delete(filename):
  """"""
  try:
    os.unlink(filename)
  except OSError as e:
    if e.errno != errno.ENOENT:
      raise
178520
def file_name_without_extension(path):
    
    if path is None:
        return None
    return os.path.splitext(os.path.basename(path))[0]
75833
def remove(filename)
      path = File.join(dir, filename)
      gzip = "#{path}.gz"
      logical_path = files[filename]['logical_path']

      if assets[logical_path] == filename
        assets.delete(logical_path)
      end

      files.delete(filename)
      FileUtils.rm(path) if File.exist?(path)
      FileUtils.rm(gzip) if File.exist?(gzip)

      save

      logger.info "Removed #{filename}"

      nil
    end
382975
def ensure_path(filename):
    
    dirname = os.path.dirname(filename)
    if dirname and not os.path.exists(dirname):
        os.makedirs(dirname)
1095047
def filename_from_path(path):
    
    head, tail = ntpath.split(path)
    return head, tail or ntpath.basename(head)
730919
def remove(path):
    
    if not os.path.exists(path):
        return

    if os.path.isdir(path):
        return shutil.rmtree(path)

    if os.path.isfile(path):
        return os.remove(path)
1099860
def __delete_path(self, path):
        

        if not foundations.common.path_exists(path):
            return

        parent_directory = os.path.dirname(path)
        is_path_registered = self.__engine.file_system_events_manager.is_path_registered(parent_directory)
        is_path_registered and self.__engine.file_system_events_manager.unregister_path(parent_directory)
        foundations.io.remove(path)
        is_path_registered and self.__engine.file_system_events_manager.register_path(parent_directory)