]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/PosixLib/Gen/access.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / StdLib / PosixLib / Gen / access.c
diff --git a/StdLib/PosixLib/Gen/access.c b/StdLib/PosixLib/Gen/access.c
deleted file mode 100644 (file)
index 3031e4f..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/** @file\r
-  Implementation of the Posix access() function.\r
-\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials are licensed and made available under\r
-  the terms and conditions of the BSD License that accompanies this distribution.\r
-  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.\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  <sys/EfiCdefs.h>\r
-\r
-#include  <ctype.h>\r
-#include  <errno.h>\r
-#include  <sys/stat.h>\r
-#include  <string.h>\r
-#include  <unistd.h>\r
-#include  <sys/syslimits.h>\r
-\r
-/** Save some typing later on. */\r
-#define GOOD_MODE   (F_OK | X_OK | W_OK | R_OK)\r
-\r
-/** Determine accessibility of a file.\r
-    The access() function checks the file, named by the pathname pointed to by\r
-    the Path argument, for accessibility according to the bit pattern contained\r
-    in Mode.\r
-\r
-    The value of Mode is either the bitwise-inclusive OR of the access\r
-    permissions to be checked (R_OK, W_OK, X_OK) or the existence test (F_OK).\r
-\r
-    If Path ends in '/' or '\\', the target must be a directory, otherwise it doesn't matter.\r
-    A file is executable if it is NOT a directory and it ends in ".efi".\r
-\r
-    @param[in]    Path    Path or name of the file to be checked.\r
-    @param[in]    Mode    Access permissions to check for.\r
-\r
-    @retval   0   Successful completion.\r
-    @retval  -1   File is not accessible with the given Mode.  The error condition\r
-                  is indicated by errno.  Values of errno specific to the access\r
-                  function include: EACCES, ENOENT, ENOTDIR, ENAMETOOLONG\r
-**/\r
-int\r
-access(\r
-  const char *Path,\r
-  int         Mode\r
-  )\r
-{\r
-  struct stat     FileStat;\r
-  int             retval      = -1;\r
-  size_t          PLength;\r
-  uint32_t        WantDir;\r
-  uint32_t        DirMatch;\r
-\r
-  if((Path == NULL) || ((Mode & ~GOOD_MODE) != 0)) {\r
-    errno = EINVAL;\r
-  }\r
-  else {\r
-    PLength = strlen(Path);\r
-    if(PLength > PATH_MAX) {\r
-      errno = ENAMETOOLONG;\r
-    }\r
-    else {\r
-      retval = stat(Path, &FileStat);\r
-      if(retval == 0) {\r
-        /* Path exists.  FileStat now holds valid information. */\r
-        WantDir   = isDirSep(Path[PLength - 1]);   // Does Path end in '/' or '\\' ?\r
-        DirMatch = (! WantDir && (! S_ISDIR(FileStat.st_mode)));\r
-\r
-        /* Test each permission individually.  */\r
-        do {\r
-          if(Mode == F_OK) {  /* Existence test. */\r
-            if(DirMatch) {    /* This is a directory or file as desired. */\r
-              retval = 0;\r
-            }\r
-            else {\r
-              /* Indicate why we failed the test. */\r
-              errno = (WantDir) ? ENOTDIR : EISDIR;\r
-            }\r
-            break;  /* F_OK does not combine with any other tests. */\r
-          }\r
-          if(Mode & R_OK) {\r
-            if((FileStat.st_mode & READ_PERMS) == 0) {\r
-              /* No read permissions.\r
-                 For UEFI, everything should have READ permissions.\r
-              */\r
-              errno = EDOOFUS;  /* Programming Error. */\r
-              break;\r
-            }\r
-          }\r
-          if(Mode & W_OK) {\r
-            if((FileStat.st_mode & WRITE_PERMS) == 0) {\r
-              /* No write permissions. */\r
-              errno = EACCES;  /* Writing is not OK. */\r
-              break;\r
-            }\r
-          }\r
-          if(Mode & X_OK) {\r
-            /* In EDK II, executable files end in ".efi" */\r
-            if(strcmp(&Path[PLength-4], ".efi") != 0) {\r
-              /* File is not an executable. */\r
-              errno = EACCES;\r
-              break;\r
-            }\r
-          }\r
-          retval = 0;\r
-        } while(FALSE);\r
-      }\r
-      else {\r
-        /* File or path does not exist. */\r
-        errno = ENOENT;\r
-      }\r
-    }\r
-  }\r
-  return retval;\r
-}\r