From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-x235.google.com (mail-it0-x235.google.com [IPv6:2607:f8b0:4001:c0b::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 457741A1DFC for ; Wed, 12 Oct 2016 10:34:38 -0700 (PDT) Received: by mail-it0-x235.google.com with SMTP id o19so61327639ito.1 for ; Wed, 12 Oct 2016 10:34:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CBWT6XsaRbHY/RQThyhwWN7OPD8PMqT27Yu2BdMkbZk=; b=drDV+6JpG8v7HODpfIAI5ojD0+GB2dzNDFsh3CEiCQ6THWPMKU688TQPRn8Tk5wFjR 2jj+nOL/aW3mWquNKwIPppm3NL1k1vs0A9WQ66HJbOeytV18wvEKFNKA8oAGKrGlyBsF RHUxYKBStB4YYwJquAuKfMOOoH2YgXzPmV38qhhLUTTZql7tUZUxV+nzEMlDSgG6dW/a ueBPKj44jGLmKi1QdxEyOxaI3Y0GpKNFJejecv+MiqYsSYr7RZWipzzojLBTt4KeWAk3 x7lsUkLgumJ1jBJ0NRZXsdUK1nT4qieCi0dbmPQa4Esf7t8KO9Qbdb6FMZjSmVeVcsE7 K5Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CBWT6XsaRbHY/RQThyhwWN7OPD8PMqT27Yu2BdMkbZk=; b=Flx58WhWhNDU3rQ5O2EDsEWUJBnvuEc2a6UGKwmz+JFLZKm3D0xCOxC74VvtmhdGtI 8vqPUlkKEEKVzAtnak2XA940K/e5KR1bKYqVANGvu5zunQENz3Hf+HvFaxyUYtElrUAz C9FRXmEEj8VToaCkarm3rnQRdV8qdOCq/WS3i5SwvhBR/sqyyS6c9fiHb22dfYoP9L3g NvVzO9V2NLffWrRdpUZjt8U/WxIdLkZNbMEQjXf22TXXW4nEI4yX2rSTLlq1jmdY0+kg qOih+xk4GmQnOFUm7Rg8pQKVFNhPpprzfEv4/G26VzUKDzyr2nEHhByRMd7CBk2xErh2 cyyg== X-Gm-Message-State: AA6/9Rmu2duMCTOwf+69aX1nB1zij1hd8GEqViRWpm1PTDDYQJMNUUZatusz0woNfhyZ2i5kKnY7iVAW8R799A== X-Received: by 10.36.147.135 with SMTP id y129mr2723805itd.11.1476293677419; Wed, 12 Oct 2016 10:34:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: GN Keshava Date: Wed, 12 Oct 2016 17:34:26 +0000 Message-ID: To: Laszlo Ersek Cc: edk2-devel-01 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: Format a volume in UEFI (or delete all files) X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 17:34:38 -0000 Content-Type: text/plain; charset=UTF-8 Thanks Laszlo, I'll check it out. I think I need to combine the LS implementation and RM implementation, isn't it? So there is no "format this volume" function or command exists, right? Thanks again! Regards, Keshava On Wed 12 Oct, 2016 8:01 pm Laszlo Ersek, wrote: > 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 > >