From: Laszlo Ersek <lersek@redhat.com>
To: GN Keshava <keshava.gn@gmail.com>
Cc: edk2-devel-01 <edk2-devel@ml01.01.org>
Subject: Re: Format a volume in UEFI (or delete all files)
Date: Wed, 12 Oct 2016 16:31:54 +0200 [thread overview]
Message-ID: <a1c36e38-2edd-db9b-a47f-a64ac8bcdc56@redhat.com> (raw)
In-Reply-To: <CABKwMdu6iTg9bVhKXzosfLpmCKOH0Cka=ZBahesri+ZTRTQ2Xw@mail.gmail.com>
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.
ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
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
ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
The CascadeDelete() function looks relevant: "Delete a node and all
nodes under it (including sub directories)".
Thanks
Laszlo
next prev parent reply other threads:[~2016-10-12 14:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-12 10:48 Format a volume in UEFI (or delete all files) GN Keshava
2016-10-12 14:31 ` Laszlo Ersek [this message]
2016-10-12 17:23 ` Blibbet
2016-10-12 17:34 ` GN Keshava
2016-10-12 17:40 ` Laszlo Ersek
2016-10-13 1:29 ` GN Keshava
2016-10-13 6:20 ` Michael Zimmermann
2016-10-13 6:26 ` GN Keshava
2016-10-13 8:33 ` Laszlo Ersek
2016-10-13 8:48 ` GN Keshava
2016-10-12 17:41 ` Blibbet
2016-10-12 17:46 ` Richardson, Brian
2016-10-12 17:55 ` Michael Zimmermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a1c36e38-2edd-db9b-a47f-a64ac8bcdc56@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox