On 10/12/16 12:48, GN Keshava wrote:
> Hi all,
> I need to format fs1: (or delete all files and folders in root directory)
> from my UEFI application.
> I'm able to use file system APIs such as Open, Write or Delete too. But
> Delete API needs File (file path) as argument, but what I want is delete
> all files (irrespective of file name).
> What could be the best method? Is there any API to directly delete all
> files? If not, How to go through (Open) all files and delete each?
> How I can get each file and folder names in a directory programmatically ?

Implement recursive directory traversal.

(Minimally) the CP, LS, and TOUCH commands support the "-r" option, for
recursive operation. I guess you could consult their implementations, if
you don't want to implement the traversal from scratch.


Actually... the RM command supports recursive file & directory removal
without additional options. The UEFI shell spec 2.2 (Jan 26, 2016) says
under RM:

    This command deletes one or more files or directories. If the
    target is a directory, it will delete the directory, including all
    its subdirectories. [...]

So I guess you could copy & customize the code from


The CascadeDelete() function looks relevant: "Delete a node and all
nodes under it (including sub directories)".


edk2-devel mailing list

Reply via email to