+++ /dev/null
-/** @file\r
- Implement the realpath function.\r
-\r
- Copyright (c) 2011 - 2014, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-**/\r
-#include <LibConfig.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <errno.h>\r
-\r
-/** The realpath() function shall derive, from the pathname pointed to by\r
- file_name, an absolute pathname that names the same file, whose resolution\r
- does not involve '.', '..', or symbolic links.\r
-\r
- The generated pathname shall be stored as a null-terminated string, up to a\r
- maximum of {PATH_MAX} bytes, in the buffer pointed to by resolved_name.\r
-\r
- If resolved_name is a null pointer, the behavior of realpath() is\r
- implementation-defined.\r
-\r
- @param[in] file_name The filename to convert.\r
- @param[in,out] resolved_name The resultant name.\r
-\r
- @retval NULL An error occured.\r
- @return resolved_name.\r
-**/\r
-char *\r
-realpath(\r
- char *file_name,\r
- char *resolved_name\r
- )\r
-{\r
- CHAR16 *Temp;\r
- if (file_name == NULL || resolved_name == NULL) {\r
- errno = EINVAL;\r
- return (NULL);\r
- }\r
- Temp = AllocateZeroPool((1+AsciiStrLen(file_name))*sizeof(CHAR16));\r
- if (Temp == NULL) {\r
- errno = ENOMEM;\r
- return (NULL);\r
- }\r
- AsciiStrToUnicodeStr(file_name, Temp);\r
- PathCleanUpDirectories(Temp);\r
- UnicodeStrToAsciiStr(Temp, resolved_name);\r
- return (resolved_name);\r
-}\r