Revision: 14138
          http://edk2.svn.sourceforge.net/edk2/?rev=14138&view=rev
Author:   jcarsey
Date:     2013-02-20 18:21:14 +0000 (Wed, 20 Feb 2013)
Log Message:
-----------
ShellPkg: Added function ShellDeleteByName which deletes a file by name.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Matthew Stanbro <[email protected]>
Reviewed-by: Jaben Carsey <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ShellPkg/Include/Library/ShellLib.h
    trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c

Modified: trunk/edk2/ShellPkg/Include/Library/ShellLib.h
===================================================================
--- trunk/edk2/ShellPkg/Include/Library/ShellLib.h      2013-02-20 08:20:14 UTC 
(rev 14137)
+++ trunk/edk2/ShellPkg/Include/Library/ShellLib.h      2013-02-20 18:21:14 UTC 
(rev 14138)
@@ -1,7 +1,7 @@
 /** @file
   Provides interface to shell functionality for shell commands and 
applications.
 
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -1328,4 +1328,33 @@
   IN OUT BOOLEAN                *Ascii
   );
 
+/**
+  Function to delete a file by name
+  
+  @param[in]       FileName       Pointer to file name to delete.
+  
+  @retval EFI_SUCCESS             the file was deleted sucessfully
+  @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not
+                                  deleted
+  @retval EFI_INVALID_PARAMETER   One of the parameters has an invalid value.
+  @retval EFI_NOT_FOUND           The specified file could not be found on the
+                                  device or the file system could not be found
+                                  on the device.
+  @retval EFI_NO_MEDIA            The device has no medium.
+  @retval EFI_MEDIA_CHANGED       The device has a different medium in it or 
the
+                                  medium is no longer supported.
+  @retval EFI_DEVICE_ERROR        The device reported an error.
+  @retval EFI_VOLUME_CORRUPTED    The file system structures are corrupted.
+  @retval EFI_WRITE_PROTECTED     The file or medium is write protected.
+  @retval EFI_ACCESS_DENIED       The file was opened read only.
+  @retval EFI_OUT_OF_RESOURCES    Not enough resources were available to open 
the
+                                  file.
+  @retval other                   The file failed to open
+**/
+EFI_STATUS
+EFIAPI
+ShellDeleteFileByName(
+  IN CONST CHAR16               *FileName
+  );
+
 #endif // __SHELL_LIB__

Modified: trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c
===================================================================
--- trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c     2013-02-20 
08:20:14 UTC (rev 14137)
+++ trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c     2013-02-20 
18:21:14 UTC (rev 14138)
@@ -1,7 +1,7 @@
 /** @file
   Provides interface to shell functionality for shell commands and 
applications.
 
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -4059,3 +4059,48 @@
 
   return (Status);
 }
+
+/**
+  Function to delete a file by name
+  
+  @param[in]       FileName       Pointer to file name to delete.
+  
+  @retval EFI_SUCCESS             the file was deleted sucessfully
+  @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not
+                                  deleted
+  @retval EFI_INVALID_PARAMETER   One of the parameters has an invalid value.
+  @retval EFI_NOT_FOUND           The specified file could not be found on the
+                                  device or the file system could not be found
+                                  on the device.
+  @retval EFI_NO_MEDIA            The device has no medium.
+  @retval EFI_MEDIA_CHANGED       The device has a different medium in it or 
the
+                                  medium is no longer supported.
+  @retval EFI_DEVICE_ERROR        The device reported an error.
+  @retval EFI_VOLUME_CORRUPTED    The file system structures are corrupted.
+  @retval EFI_WRITE_PROTECTED     The file or medium is write protected.
+  @retval EFI_ACCESS_DENIED       The file was opened read only.
+  @retval EFI_OUT_OF_RESOURCES    Not enough resources were available to open 
the
+                                  file.
+  @retval other                   The file failed to open
+**/
+EFI_STATUS
+EFIAPI
+ShellDeleteFileByName(
+  IN CONST CHAR16               *FileName
+  )
+{
+  EFI_STATUS                Status;
+  SHELL_FILE_HANDLE         FileHandle;
+  
+  Status = ShellFileExists(FileName);
+  
+  if (Status == EFI_SUCCESS){
+    Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ | 
EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0x0);
+    if (Status == EFI_SUCCESS){
+      Status = ShellDeleteFile(&FileHandle);
+    }
+  } 
+
+  return(Status);
+  
+}

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to