]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Include/Library/FileHandleLib.h
udk2010.up2.shell initial release.
[mirror_edk2.git] / ShellPkg / Include / Library / FileHandleLib.h
index c0cde036f9d45a2956e1e106653124036c8594c7..1c191ad64a27b2e73aa8d34737e0bc65148c97ec 100644 (file)
 \r
 **/\r
 \r
-#if !defined (_FILE_HANDLE_LIBRARY_HEADER_)\r
+#ifndef _FILE_HANDLE_LIBRARY_HEADER_\r
 #define _FILE_HANDLE_LIBRARY_HEADER_\r
 \r
-/// Tag for use in identifying UNICODE files.\r
-/// If the file is UNICODE the first 16 bits of the file will equal this value.\r
+#include <Protocol/SimpleFileSystem.h>\r
+\r
+/// The tag for use in identifying UNICODE files.\r
+/// If the file is UNICODE, the first 16 bits of the file will equal this value.\r
 enum {\r
   UnicodeFileTag = 0xFEFF\r
 };\r
 \r
 /**\r
-  This function will retrieve the information about the file for the handle\r
-  specified and store it in allocated pool memory.\r
+  This function retrieves information about the file for the handle\r
+  specified and stores it in the allocated pool memory.\r
 \r
   This function allocates a buffer to store the file's information. It is the\r
   caller's responsibility to free the buffer.\r
 \r
-  @param  FileHandle  The file handle of the file for which information is\r
-                      being requested.\r
-\r
-  @retval NULL        information could not be retrieved.\r
+  @param[in] FileHandle         The file handle of the file for which information is\r
+                                being requested.\r
 \r
-  @retval !NULL       the information about the file\r
+  @retval NULL                  Information could not be retrieved.\r
+  @retval !NULL                 The information about the file.\r
 **/\r
 EFI_FILE_INFO*\r
 EFIAPI\r
@@ -42,23 +43,23 @@ FileHandleGetInfo (
   );\r
 \r
 /**\r
-  This function will set the information about the file for the opened handle\r
+  This function sets the information about the file for the opened handle\r
   specified.\r
 \r
-  @param  FileHandle            The file handle of the file for which information\r
+  @param[in]  FileHandle        The file handle of the file for which information\r
                                 is being set.\r
 \r
-  @param  FileInfo              The information to set.\r
+  @param[in]  FileInfo          The information to set.\r
 \r
   @retval EFI_SUCCESS                  The information was set.\r
-  @retval EFI_INVALID_PARAMETER A Parameter was out of range or invalid.\r
+  @retval EFI_INVALID_PARAMETER A parameter was out of range or invalid.\r
   @retval EFI_UNSUPPORTED       The FileHandle does not support FileInfo.\r
   @retval EFI_NO_MEDIA               The device has no medium.\r
   @retval EFI_DEVICE_ERROR         The device reported an error.\r
   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
   @retval EFI_WRITE_PROTECTED    The file or medium is write protected.\r
-  @retval EFI_ACCESS_DENIED        The file was opened read only.\r
-  @retval EFI_VOLUME_FULL            The volume is full.\r
+  @retval EFI_ACCESS_DENIED     The file was opened read only.\r
+  @retval EFI_VOLUME_FULL       The volume is full.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -83,16 +84,16 @@ FileHandleSetInfo (
   are no more directory entries, the read returns a zero-length buffer.\r
   EFI_FILE_INFO is the structure returned as the directory entry.\r
 \r
-  @param FileHandle             The opened file handle.\r
-  @param BufferSize             On input the size of buffer in bytes.  On return\r
+  @param[in] FileHandle         The opened file handle.\r
+  @param[in,out] BufferSize     On input, the size of buffer in bytes.  On return,\r
                                 the number of bytes written.\r
-  @param Buffer                 The buffer to put read data into.\r
+  @param[out] Buffer            The buffer to put read data into.\r
 \r
-  @retval EFI_SUCCESS            Data was read.\r
+  @retval EFI_SUCCESS          Data was read.\r
   @retval EFI_NO_MEDIA         The device has no media.\r
-  @retval EFI_DEVICE_ERROR         The device reported an error.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error.\r
   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_BUFFER_TO_SMALL    Buffer is too small. ReadSize contains required\r
+  @retval EFI_BUFFER_TO_SMALL  Buffer is too small. ReadSize contains required\r
                                 size.\r
 \r
 **/\r
@@ -114,19 +115,19 @@ FileHandleRead(
   The file is automatically grown to hold the data if required. Direct writes to\r
   opened directories are not supported.\r
 \r
-  @param FileHandle             The opened file for writing\r
-  @param BufferSize             On input the number of bytes in Buffer.  On output\r
+  @param[in] FileHandle         The opened file for writing.\r
+  @param[in,out] BufferSize     On input, the number of bytes in Buffer.  On output,\r
                                 the number of bytes written.\r
-  @param Buffer                 The buffer containing data to write is stored.\r
+  @param[in] Buffer             The buffer containing data to write is stored.\r
 \r
-  @retval EFI_SUCCESS            Data was written.\r
-  @retval EFI_UNSUPPORTED            Writes to an open directory are not supported.\r
+  @retval EFI_SUCCESS          Data was written.\r
+  @retval EFI_UNSUPPORTED       Writes to an open directory are not supported.\r
   @retval EFI_NO_MEDIA         The device has no media.\r
-  @retval EFI_DEVICE_ERROR         The device reported an error.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error.\r
   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED    The device is write-protected.\r
-  @retval EFI_ACCESS_DENIED        The file was open for read only.\r
-  @retval EFI_VOLUME_FULL            The volume is full.\r
+  @retval EFI_WRITE_PROTECTED  The device is write-protected.\r
+  @retval EFI_ACCESS_DENIED    The file was opened for read only.\r
+  @retval EFI_VOLUME_FULL      The volume is full.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -143,9 +144,9 @@ FileHandleWrite(
   flushed to the device, and the file is closed. In all cases the handle is\r
   closed.\r
 \r
-  @param FileHandle               The file handle to close.\r
+  @param[in] FileHandle           The file handle to close.\r
 \r
-  @retval EFI_SUCCESS             The file handle was closed sucessfully.\r
+  @retval EFI_SUCCESS             The file handle was closed successfully.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -160,11 +161,11 @@ FileHandleClose (
   If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is\r
   returned, but the handle is still closed.\r
 \r
-  @param FileHandle             The file handle to delete.\r
+  @param[in] FileHandle             The file handle to delete.\r
 \r
-  @retval EFI_SUCCESS               The file was closed sucessfully.\r
-  @retval EFI_WARN_DELETE_FAILURE   the handle was closed, but the file was not\r
-                                    deleted\r
+  @retval EFI_SUCCESS               The file was closed successfully.\r
+  @retval EFI_WARN_DELETE_FAILURE   The handle was closed, but the file was not\r
+                                    deleted.\r
   @retval INVALID_PARAMETER                One of the parameters has an invalid value.\r
 **/\r
 EFI_STATUS\r
@@ -177,18 +178,18 @@ FileHandleDelete (
   Set the current position in a file.\r
 \r
   This function sets the current file position for the handle to the position\r
-  supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only\r
-  absolute positioning is supported, and seeking past the end of the file is\r
-  allowed (a subsequent write would grow the file). Seeking to position\r
+  supplied. With the exception of moving to position 0xFFFFFFFFFFFFFFFF, only\r
+  absolute positioning is supported, and moving past the end of the file is\r
+  allowed (a subsequent write would grow the file). Moving to position\r
   0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r
   If FileHandle is a directory, the only position that may be set is zero. This\r
-  has the effect of starting the read process of the directory entries over.\r
+  has the effect of starting the read process of the directory entries over again.\r
 \r
-  @param FileHandle             The file handle on which the position is being set\r
-  @param Position               Byte position from begining of file\r
+  @param[in] FileHandle         The file handle on which the position is being set.\r
+  @param[in] Position           The byte position from the begining of the file.\r
 \r
-  @retval EFI_SUCCESS           Operation completed sucessfully.\r
-  @retval EFI_UNSUPPORTED       the seek request for non-zero is not valid on\r
+  @retval EFI_SUCCESS           The operation completed sucessfully.\r
+  @retval EFI_UNSUPPORTED       The request for non-zero is not valid on\r
                                 directories.\r
   @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
 **/\r
@@ -204,15 +205,15 @@ FileHandleSetPosition (
 \r
   This function retrieves the current file position for the file handle. For\r
   directories, the current file position has no meaning outside of the file\r
-  system driver and as such the operation is not supported. An error is returned\r
+  system driver. As such, the operation is not supported. An error is returned\r
   if FileHandle is a directory.\r
 \r
-  @param FileHandle             The open file handle on which to get the position.\r
-  @param Position               Byte position from begining of file.\r
+  @param[in] FileHandle         The open file handle on which to get the position.\r
+  @param[out] Position          The byte position from begining of file.\r
 \r
-  @retval EFI_SUCCESS           the operation completed sucessfully.\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
   @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
-  @retval EFI_UNSUPPORTED       the request is not valid on directories.\r
+  @retval EFI_UNSUPPORTED       The request is not valid on directories.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -225,7 +226,7 @@ FileHandleGetPosition (
 \r
   This function flushes all modified data associated with a file to a device.\r
 \r
-  @param FileHandle             The file handle on which to flush data.\r
+  @param[in] FileHandle         The file handle on which to flush data.\r
 \r
   @retval EFI_SUCCESS           The data was flushed.\r
   @retval EFI_NO_MEDIA          The device has no media.\r
@@ -243,16 +244,16 @@ FileHandleFlush (
 /**\r
   Function to determine if a given handle is a directory handle.\r
 \r
-  If DirHandle is NULL then ASSERT().\r
+  If DirHandle is NULL, then ASSERT().\r
 \r
-  Open the file information on the DirHandle and verify that the Attribute\r
+  Open the file information on the DirHandle, and verify that the Attribute\r
   includes EFI_FILE_DIRECTORY bit set.\r
 \r
-  @param DirHandle              Handle to open file.\r
+  @param[in] DirHandle          The handle to open the file.\r
 \r
-  @retval EFI_SUCCESS           DirHandle is a directory\r
-  @retval EFI_INVALID_PARAMETER DirHandle did not have EFI_FILE_INFO available\r
-  @retval EFI_NOT_FOUND         DirHandle is not a directory\r
+  @retval EFI_SUCCESS           DirHandle is a directory.\r
+  @retval EFI_INVALID_PARAMETER DirHandle did not have EFI_FILE_INFO available.\r
+  @retval EFI_NOT_FOUND         DirHandle is not a directory.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -263,20 +264,20 @@ FileHandleIsDirectory (
 /**\r
   Retrieves the first file from a directory.\r
 \r
-  This function opens a directory and gets the first file's info in the\r
-  directory. Caller can use FileHandleFindNextFile() to get other files.  When\r
-  complete the caller is responsible for calling FreePool() on *Buffer.\r
+  This function opens a directory and gets the first file's information in the\r
+  directory. The caller the uses FileHandleFindNextFile() to get other files.  When\r
+  complete, the caller is responsible for calling FreePool() on *Buffer.\r
 \r
-  @param DirHandle              The file handle of the directory to search\r
-  @param Buffer                 Pointer to pointer to buffer for file's information\r
+  @param[in] DirHandle          The file handle of the directory to search.\r
+  @param[out] Buffer            The pointer to pointer to buffer for file's information.\r
 \r
   @retval EFI_SUCCESS           Found the first file.\r
   @retval EFI_NOT_FOUND         Cannot find the directory.\r
   @retval EFI_NO_MEDIA          The device has no media.\r
   @retval EFI_DEVICE_ERROR      The device reported an error.\r
   @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-  @return Others                status of FileHandleGetInfo, FileHandleSetPosition,\r
-                                or FileHandleRead\r
+  @return Others                The status of FileHandleGetInfo, FileHandleSetPosition,\r
+                                or FileHandleRead.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -294,11 +295,11 @@ FileHandleFindFirstFile (
   call of this function has no file to get. *NoFile will be set to TRUE and the\r
   Buffer memory will be automatically freed.\r
 \r
-  @param DirHandle              the file handle of the directory\r
-  @param Buffer                                    pointer to buffer for file's information\r
-  @param NoFile                                    pointer to boolean when last file is found\r
+  @param[in] DirHandle          The file handle of the directory.\r
+  @param[out] Buffer            The pointer to buffer for file's information.\r
+  @param[out] NoFile            The pointer to boolean when last file is found.\r
 \r
-  @retval EFI_SUCCESS           Found the next file, or reached last file\r
+  @retval EFI_SUCCESS           Found the next file, or reached last file.\r
   @retval EFI_NO_MEDIA          The device has no media.\r
   @retval EFI_DEVICE_ERROR      The device reported an error.\r
   @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
@@ -314,17 +315,17 @@ FileHandleFindNextFile(
 /**\r
   Retrieve the size of a file.\r
 \r
-  If FileHandle is NULL then ASSERT()\r
-  If Size is NULL then ASSERT()\r
+  If FileHandle is NULL then ASSERT().\r
+  If Size is NULL then ASSERT().\r
 \r
   This function extracts the file size info from the FileHandle's EFI_FILE_INFO\r
   data.\r
 \r
-  @param FileHandle             The file handle from which size is retrieved.\r
-  @param Size                   pointer to size.\r
+  @param[in] FileHandle         The file handle from which size is retrieved.\r
+  @param[out] Size              The pointer to size.\r
 \r
-  @retval EFI_SUCCESS           operation was completed sucessfully\r
-  @retval EFI_DEVICE_ERROR      cannot access the file\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_DEVICE_ERROR      Cannot access the file.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -333,6 +334,27 @@ FileHandleGetSize (
   OUT UINT64                    *Size\r
   );\r
 \r
+/**\r
+  Set the size of a file.\r
+\r
+  If FileHandle is NULL then ASSERT().\r
+\r
+  This function changes the file size info from the FileHandle's EFI_FILE_INFO\r
+  data.\r
+\r
+  @param[in] FileHandle         The file handle whose size is to be changed.\r
+  @param[in] Size               The new size.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_DEVICE_ERROR      Cannot access the file.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleSetSize (\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN UINT64                     Size\r
+  );\r
+\r
 /**\r
   Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the\r
   directory 'stack'.\r
@@ -341,10 +363,10 @@ FileHandleGetSize (
   @param[out] FullFileName      Pointer to pointer to generated full file name.  It\r
                                 is the responsibility of the caller to free this memory\r
                                 with a call to FreePool().\r
-  @retval EFI_SUCCESS           the operation was sucessful and the FullFileName is valid.\r
+  @retval EFI_SUCCESS           The operation was successful and FullFileName is valid.\r
   @retval EFI_INVALID_PARAMETER Handle was NULL.\r
   @retval EFI_INVALID_PARAMETER FullFileName was NULL.\r
-  @retval EFI_OUT_OF_MEMORY     a memory allocation failed.\r
+  @retval EFI_OUT_OF_MEMORY     A memory allocation failed.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -359,21 +381,24 @@ FileHandleGetFileName (
   If the position upon start is 0, then the Ascii Boolean will be set.  This should be\r
   maintained and not changed for all operations with the same file.\r
 \r
-  @param[in]      Handle        FileHandle to read from\r
-  @param[in,out]  Buffer        pointer to buffer to read into\r
-  @param[in,out]  Size          pointer to number of bytes in buffer\r
-  @param[in]      Truncate      if TRUE then allows for truncation of the line to fit.\r
-                                if FALSE will reset the position to the begining of the\r
-                                line if the buffer is not large enough.\r
+  @param[in]      Handle        FileHandle to read from.\r
+  @param[in,out]  Buffer        The pointer to buffer to read into.\r
+  @param[in,out]  Size          The pointer to number of bytes in Buffer.\r
+  @param[in]      Truncate      If the buffer is large enough, this has no effect.\r
+                                If the buffer is is too small and Truncate is TRUE,\r
+                                the line will be truncated.\r
+                                If the buffer is is too small and Truncate is FALSE,\r
+                                then no read will occur.\r
+\r
   @param[in,out]  Ascii         Boolean value for indicating whether the file is\r
-                                Ascii (TRUE) or UCS2 (FALSE);\r
+                                Ascii (TRUE) or UCS2 (FALSE).\r
 \r
-  @retval EFI_SUCCESS           the operation was sucessful.  the line is stored in\r
+  @retval EFI_SUCCESS           The operation was successful.  The line is stored in\r
                                 Buffer.\r
   @retval EFI_INVALID_PARAMETER Handle was NULL.\r
   @retval EFI_INVALID_PARAMETER Size was NULL.\r
-  @retval EFI_BUFFER_TOO_SMALL  Size was not enough space to store the line.\r
-                                Size was updated to minimum space required.\r
+  @retval EFI_BUFFER_TOO_SMALL  Size was not large enough to store the line.\r
+                                Size was updated to the minimum space required.\r
   @sa FileHandleRead\r
 **/\r
 EFI_STATUS\r
@@ -394,7 +419,8 @@ FileHandleReadLine(
   maintained and not changed for all operations with the same file.\r
 \r
   @param[in]      Handle        FileHandle to read from.\r
-  @param[in,out]  Ascii         Boolean value for indicating whether the file is Ascii (TRUE) or UCS2 (FALSE);\r
+  @param[in,out]  Ascii         Boolean value for indicating whether the file is\r
+                                Ascii (TRUE) or UCS2 (FALSE).\r
 \r
   @return                       The line of text from the file.\r
 \r
@@ -412,12 +438,12 @@ FileHandleReturnLine(
 \r
   If Handle is NULL, ASSERT.\r
 \r
-  @param[in]     Handle         FileHandle to write to\r
+  @param[in]     Handle         FileHandle to write to.\r
   @param[in]     Buffer         Buffer to write, if NULL the function will\r
                                 take no action and return EFI_SUCCESS.\r
 \r
-  @retval  EFI_SUCCESS          the data was written.\r
-  @retval  other                failure.\r
+  @retval  EFI_SUCCESS          The data was written.\r
+  @retval  other                Failure.\r
 \r
   @sa FileHandleWrite\r
 **/\r
@@ -429,14 +455,14 @@ FileHandleWriteLine(
   );\r
 \r
 /**\r
-  function to take a formatted argument and print it to a file.\r
+  Function to take a formatted argument and print it to a file.\r
 \r
-  @param[in] Handle   the file handle for the file to write to\r
-  @param[in] Format   the format argument (see printlib for format specifier)\r
-  @param[in] ...      the variable arguments for the format\r
+  @param[in] Handle   The file handle for the file to write to.\r
+  @param[in] Format   The format argument (see printlib for the format specifier).\r
+  @param[in] ...      The variable arguments for the format.\r
 \r
-  @retval EFI_SUCCESS the operation was sucessful\r
-  @return other       a return value from FileHandleWriteLine\r
+  @retval EFI_SUCCESS The operation was successful.\r
+  @retval other       A return value from FileHandleWriteLine.\r
 \r
   @sa FileHandleWriteLine\r
 **/\r
@@ -453,12 +479,12 @@ FileHandlePrintLine(
 \r
   This will NOT work on directories.\r
 \r
-  If Handle is NULL, then ASSERT.\r
+  If Handle is NULL, then ASSERT().\r
 \r
-  @param[in] Handle     the file handle\r
+  @param[in] Handle     The file handle.\r
 \r
-  @retval TRUE          the position is at the end of the file\r
-  @retval FALSE         the position is not at the end of the file\r
+  @retval TRUE          The position is at the end of the file.\r
+  @retval FALSE         The position is not at the end of the file.\r
 **/\r
 BOOLEAN\r
 EFIAPI\r