]> granicus.if.org Git - graphviz/commitdiff
remove now-unused pathexists.c
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 4 Aug 2021 04:23:13 +0000 (21:23 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 10 Aug 2021 14:54:00 +0000 (07:54 -0700)
The caching done by this function is no longer necessary. All usages of it have
been refactored to use standard library functionality which does caching at the
operating system level.

lib/ast/CMakeLists.txt
lib/ast/Makefile.am
lib/ast/ast.h
lib/ast/ast.vcxproj
lib/ast/ast.vcxproj.filters
lib/ast/pathexists.c [deleted file]

index bd877d16553fffb7ed2039528e91805256fefd2c..acc60a00a93eb2f2837f0fc771f57ae154d9527d 100644 (file)
@@ -15,7 +15,6 @@ add_library(ast STATIC
     pathaccess.c
     pathcanon.c
     pathcat.c
-    pathexists.c
     pathfind.c
     pathgetlink.c
     strcopy.c
index 1d4b23205ec86e5b3bbf92fae7b03836267e1972..68f8cc4158c63a7e13dc87dbe482952ab65e325e 100644 (file)
@@ -7,7 +7,7 @@ noinst_LTLIBRARIES = libast_C.la
 
 libast_C_la_SOURCES = pathpath.c sfstr.h chresc.c chrtoi.c error.c \
        fmtbuf.c fmtesc.c pathaccess.c pathcanon.c pathcat.c \
-       pathexists.c pathfind.c pathgetlink.c \
+       pathfind.c pathgetlink.c \
        strcopy.c stresc.c strmatch.c
 
 EXTRA_DIST = compat_unistd.h ast.vcxproj*
index a4bd5df79c1ac0306644c8ea4c8835b6f247625f..683681ae6532eea2647574f55c83703dde7ebb67 100644 (file)
@@ -71,7 +71,6 @@ extern "C" {
     extern char *pathcat(char *, const char *, int, const char *,
                         const char *);
     extern size_t pathgetlink(const char *, char *, size_t);
-    extern int pathexists(char *, int);
 
     extern int chresc(const char *, char **);
     extern int chrtoi(const char *);
index cbb8b59feee8433481985ca592636d55a652e8be..b0a9220e8e9d125a98987724617124457c745428 100644 (file)
@@ -91,7 +91,6 @@
     <ClCompile Include="pathaccess.c" />
     <ClCompile Include="pathcanon.c" />
     <ClCompile Include="pathcat.c" />
-    <ClCompile Include="pathexists.c" />
     <ClCompile Include="pathfind.c" />
     <ClCompile Include="pathgetlink.c" />
     <ClCompile Include="pathpath.c" />
index e79907f86664ffbc205af4c19010c25e3ac87c27..3f3bc9e3eca2b49f05392e942675127fbc0b5c07 100644 (file)
@@ -56,9 +56,6 @@
     <ClCompile Include="pathcat.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="pathexists.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="pathfind.c">
       <Filter>Source Files</Filter>
     </ClCompile>
diff --git a/lib/ast/pathexists.c b/lib/ast/pathexists.c
deleted file mode 100644 (file)
index 3710d24..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/*
- * Glenn Fowler
- * AT&T Research
- *
- * return 1 if path exisis
- * maintains a cache to minimize stat(2) calls
- * path is modified in-place but restored on return
- * path components checked in pairs to cut stat()'s
- * in half by checking ENOTDIR vs. ENOENT
- */
-
-#include <ast/ast.h>
-#include <ast/error.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef _WIN32
-#include <ast/compat_unistd.h>
-#endif
-
-typedef struct Tree_s {
-    struct Tree_s *next;
-    struct Tree_s *tree;
-    int mode;
-    char name[1];
-} Tree_t;
-
-int pathexists(char *path, int mode)
-{
-    char *s;
-    char *e;
-    Tree_t *p;
-    Tree_t *t;
-    char c;
-    char *ee;
-    char cc = '\0';
-    int x;
-    struct stat st;
-
-    static Tree_t tree;
-
-    t = &tree;
-    e = path + 1;
-    c = *path;
-    while (c) {
-       p = t;
-       for (s = e; *e && *e != '/'; e++);
-       c = *e;
-       *e = 0;
-       for (t = p->tree; t && !streq(s, t->name); t = t->next);
-       if (!t) {
-           if (!(t = newof(0, Tree_t, 1, strlen(s)))) {
-               *e = c;
-               return 0;
-           }
-           strcpy(t->name, s);
-           t->next = p->tree;
-           p->tree = t;
-           if (c) {
-               *e = c;
-               for (s = ee = e + 1; *ee && *ee != '/'; ee++);
-               cc = *ee;
-               *ee = 0;
-           } else
-               ee = 0;
-           x = stat(path, &st);
-           if (ee) {
-               e = ee;
-               c = cc;
-               if (!x || errno == ENOENT)
-                   t->mode = PATH_READ | PATH_EXECUTE;
-               if (!(p = newof(0, Tree_t, 1, strlen(s)))) {
-                   *e = c;
-                   return 0;
-               }
-               strcpy(p->name, s);
-               p->next = t->tree;
-               t->tree = p;
-               t = p;
-           }
-           if (x) {
-               *e = c;
-               return 0;
-           }
-           if (st.st_mode & (S_IRUSR | S_IRGRP | S_IROTH))
-               t->mode |= PATH_READ;
-           if (st.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH))
-               t->mode |= PATH_WRITE;
-           if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
-               t->mode |= PATH_EXECUTE;
-           if (!S_ISDIR(st.st_mode))
-               t->mode |= PATH_REGULAR;
-       }
-       *e++ = c;
-       if (!t->mode || (c && (t->mode & PATH_REGULAR)))
-           return 0;
-    }
-    mode &= (PATH_READ | PATH_WRITE | PATH_EXECUTE | PATH_REGULAR);
-    return (t->mode & mode) == mode;
-}