]> Dogcows Code - chaz/tar/blobdiff - src/names.c
Take regexps into account
[chaz/tar] / src / names.c
index 8301a3e2b48e6209ab4545caf408354c820eb969..46581e0738f5228ed542a8af4ee29e983766f44e 100644 (file)
@@ -595,6 +595,17 @@ name_match (const char *path)
     }
 }
 
+/* Returns true if all names from the namelist were processed */
+bool
+names_done ()
+{
+  struct name const *cursor;
+  for (cursor = namelist; cursor; cursor = cursor->next)
+    if (cursor->regexp || (!cursor->found && !cursor->fake))
+      return false;
+  return true;
+}
+
 /* Print the names of things in the namelist that were not matched.  */
 void
 names_notfound (void)
@@ -1043,6 +1054,31 @@ safer_name_suffix (char const *file_name, bool link_target)
   return (char *) p;
 }
 \f
+/* Return the size of the prefix of FILE_NAME that is removed after
+   stripping NUM leading path name components.  NUM must be
+   positive.  */
+
+size_t
+stripped_prefix_len (char const *file_name, size_t num)
+{
+  char const *p = file_name + FILESYSTEM_PREFIX_LEN (file_name);
+  while (ISSLASH (*p))
+    p++;
+  while (*p)
+    {
+      bool slash = ISSLASH (*p);
+      p++;
+      if (slash)
+       {
+         if (--num == 0)
+           return p - file_name;
+         while (ISSLASH (*p))
+           p++;
+       }
+    }
+  return -1;
+}
+\f
 /* Return nonzero if NAME contains ".." as a path name component.  */
 bool
 contains_dot_dot (char const *name)
This page took 0.021219 seconds and 4 git commands to generate.