A wrapper around {@link FileSystem#delete(Path, boolean)} that only deletes a given {@link Path} if it is present
on the given {@link FileSystem}.
968789
public static void deleteIfExists(FileSystem fs, Path path, boolean recursive) throws IOException {
    if (fs.exists(path)) {
      deletePath(fs, path, recursive);
    }
  }
423164
public static boolean fullyDelete(File dir) throws IOException {
    boolean deleted = true;
    File contents[] = dir.listFiles();
    if (contents != null) {
      for (int i = 0; i < contents.length; i++) {
        if (contents[i].isFile()) {
          if (!contents[i].delete()) {
            deleted = false;
          }
        } else {
          //try deleting the directory
          // this might be a symlink
          boolean b = false;
          b = contents[i].delete();
          if (b){
            //this was indeed a symlink or an empty directory
            continue;
          }
          // if not an empty directory or symlink let
          // fullydelete handle it.
          if (!fullyDelete(contents[i])) {
            deleted = false;
          }
        }
      }
    }
    return dir.delete() && deleted;
  }
30325
public void deletePath(String path) {
        if (path == null) {
            return;
        }
        String[] pathComponents = path.split("/");
        TrieNode parent = rootNode;
        String part = null;
        if (pathComponents.length <= 1) {
            throw new IllegalArgumentException("Invalid path " + path);
        }
        for (int i=1; i<pathComponents.length; i++) {
            part = pathComponents[i];
            if (parent.getChild(part) == null) {
                //the path does not exist
                return;
            }
            parent = parent.getChild(part);
            LOG.info(parent);
        }
        TrieNode realParent  = parent.getParent();
        realParent.deleteChild(part);
    }
11272
protected boolean deleteDirectory(Path path, boolean cleanParent) throws IOException {
        boolean pathExists = deleteIfExistsRecursively(path);
        if(pathExists && cleanParent) {
            cleanEmptyParentDirectory(path.getParent());
            return true;
        }
        return false;
    }
1179281
public void deleteFile(JimfsPath path, DeleteMode deleteMode) throws IOException {
    store.writeLock().lock();
    try {
      DirectoryEntry entry = lookUp(path, Options.NOFOLLOW_LINKS).requireExists(path);
      delete(entry, deleteMode, path);
    } finally {
      store.writeLock().unlock();
    }
  }
1028319
public static boolean delete(File f) {
		if (f == null || !f.exists()) return true;
		if (f.isDirectory()) {
			File[] subFiles = f.listFiles();
			if (subFiles != null) {
				for (File sf : subFiles) {
					IOUtil.delete(sf);
				}
			}
		}
		return f.delete();
	}
782250
public static boolean del(Path path) throws IORuntimeException {
		if (Files.notExists(path)) {
			return true;
		}

		try {
			if (Files.isDirectory(path)) {
				Files.walkFileTree(path, new SimpleFileVisitor<Path>() {

					@Override
					public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
						Files.delete(file);
						return FileVisitResult.CONTINUE;
					}

					@Override
					public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException {
						if (e == null) {
							Files.delete(dir);
							return FileVisitResult.CONTINUE;
						} else {
							throw e;
						}
					}
				});
			} else {
				Files.delete(path);
			}
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
		return true;
	}
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)
1002528
public void delete(final String path, int version, VoidCallback cb,
            Object ctx) {
        verbotenThreadCheck();
        final String clientPath = path;
        PathUtils.validatePath(clientPath);

        final String serverPath;

        // maintain semantics even in chroot case
        // specifically - root cannot be deleted
        // I think this makes sense even in chroot case.
        if (clientPath.equals("/")) {
            // a bit of a hack, but delete(/) will never succeed and ensures
            // that the same semantics are maintained
            serverPath = clientPath;
        } else {
            serverPath = prependChroot(clientPath);
        }

        RequestHeader h = new RequestHeader();
        h.setType(ZooDefs.OpCode.delete);
        DeleteRequest request = new DeleteRequest();
        request.setPath(serverPath);
        request.setVersion(version);
        cnxn.queuePacket(h, new ReplyHeader(), request, null, cb, clientPath,
                serverPath, ctx, null);
    }
1207772
public void deleteNode(String path) {

        try {

            zk.delete(path, -1);

        } catch (KeeperException.NoNodeException e) {

            LOGGER.error("cannot delete path: " + path, e);

        } catch (InterruptedException e) {

            LOGGER.warn(e.toString());

        } catch (KeeperException e) {

            LOGGER.error("cannot delete path: " + path, e);
        }
    }
689938
def delete_files(paths):
    
    for path in paths:
        if os.path.exists(path):
            os.remove(path)
500543
public function delete() {

		$this->purge();

		if(!@rmdir($this->path)) {
			throw new FilesystemFolderException(sprintf('Filesystem folder %s could not be deleted!', $this->path));
		}

		self::unsetInstance($this->path);

	}
264411
public Delete delete(String path) {
        Delete command = new Delete();
        command.path(path);
        command.version(DEFAULT_VERSION);
        action.setCommand(command);
        return command;
    }
686160
def delete(path, fatal=True, logger=LOG.debug):
    
    islink = path and os.path.islink(path)
    if not islink and (not path or not os.path.exists(path)):
        return 0

    if is_dryrun():
        LOG.debug("Would delete %s", short(path))
        return 1

    if logger:
        logger("Deleting %s", short(path))

    try:
        if islink or os.path.isfile(path):
            os.unlink(path)
        else:
            shutil.rmtree(path)
        return 1

    except Exception as e:
        return abort("Can't delete %s: %s", short(path), e, fatal=(fatal, -1))
1094893
public static void delete(String path, String acceptType, Route route) {
        getInstance().delete(path, acceptType, route);
    }
762113
public void deletePath(final Path path, final boolean recursive) {
    this.futures.add(new NamedFuture(this.executor.submit(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        Lock lock = ParallelRunner.this.locks.get(path.toString());
        lock.lock();
        try {
          HadoopUtils.deletePath(ParallelRunner.this.fs, path, recursive);
          return null;
        } finally {
          lock.unlock();
        }
      }
    }), "Delete path " + path));
  }
61060
public static boolean delete(File f) throws IOException
	{
		assert (f.exists());

		if (f.isDirectory())
		{
			FileUtils.deleteDirectory(f);
			return true;
		}
		else
		{
			return f.delete();
		}
	}