Supported by libMapRClient for hadoop-0.20.2 and hadoop-2.x

Deletes the specified directory or file.


int hdfsDelete(hdfsFS fs, const char* path, int recursive)



The handle of the filesystem where the file or directory to delete is located. Obtain this handle with one of the hdfsConnect() APIs.


The path of the file.


A value of 0 deletes the specified directory, if the directory is empty. If the directory is not empty, an error is returned.

A non-zero value deletes the specified directory and all of its subdirectories.

If the specified object is a file, not a directory, this parameter is ignored.

Return Value

Returns 0 on success, -1 on error.

Check errno for error codes and meanings. Some of the key errors are ESTALE, EACCES, and EPERM.