Exemple #1
0
char *
normalize_filename (int cdidx, const char *name)
{
  char *copy = NULL;

  if (IS_RELATIVE_FILE_NAME (name))
    {
      /* Set COPY to the absolute path for this name.

         FIXME: There should be no need to get the absolute file name.
         tar_getcdpath does not return a true "canonical" path, so
         this following approach may lead to situations where the same
         file or directory is processed twice under different absolute
         paths without that duplication being detected.  Perhaps we
         should use dev+ino pairs instead of names?  */
      const char *cdpath = tar_getcdpath (cdidx);
      size_t copylen;
      bool need_separator;

      if (!cdpath)
	call_arg_fatal ("getcwd", ".");
      copylen = strlen (cdpath);
      need_separator = ! (DOUBLE_SLASH_IS_DISTINCT_ROOT
			  && copylen == 2 && ISSLASH (cdpath[1]));
      copy = xmalloc (copylen + need_separator + strlen (name) + 1);
      strcpy (copy, cdpath);
      copy[copylen] = DIRECTORY_SEPARATOR;
      strcpy (copy + copylen + need_separator, name);
    }

  if (!copy)
    copy = xstrdup (name);
  normalize_filename_x (copy);
  return copy;
}
Exemple #2
0
/* Fork, aborting if unsuccessful.  */
pid_t
xfork (void)
{
  pid_t p = fork ();
  if (p == (pid_t) -1)
    call_arg_fatal ("fork", _("child process"));
  return p;
}
Exemple #3
0
/* Create a pipe, aborting if unsuccessful.  */
void
xpipe (int fd[2])
{
  if (pipe (fd) < 0)
    call_arg_fatal ("pipe", _("interprocess channel"));
}
Exemple #4
0
void
write_fatal (char const *name)
{
  call_arg_fatal ("write", name);
}
Exemple #5
0
void
read_fatal (char const *name)
{
  call_arg_fatal ("read", name);
}
Exemple #6
0
void
open_fatal (char const *name)
{
  call_arg_fatal ("open", name);
}
Exemple #7
0
void
exec_fatal (char const *name)
{
  call_arg_fatal ("exec", name);
}
Exemple #8
0
void
chdir_fatal (char const *name)
{
  call_arg_fatal ("chdir", name);
}
Exemple #9
0
void
stat_fatal (char const *name)
{
  call_arg_fatal ("stat", name);
}