]>
Dogcows Code - chaz/tar/blob - src/mangle.c
1 /* Encode long filenames for GNU tar.
2 Copyright (C) 1988, 1992, 1994, 1996, 1997 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 2, or (at your option) any later
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12 Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 59 Place - Suite 330, Boston, MA 02111-1307, USA. */
29 char mangled
[NAME_FIELD_SIZE
];
34 /* Should use a hash table, etc. . */
35 struct mangled
*first_mangle
;
38 /*---------------------------------------------------------------------.
39 | Extract a GNUTYPE_NAMES record contents. It seems that such are not |
40 | produced anymore by GNU tar, but we leave the reading code around |
41 | nevertheless, for salvaging old tapes. |
42 `---------------------------------------------------------------------*/
47 int size
= current_stat
.st_size
;
48 char *buffer
= xmalloc ((size_t) (size
+ 1));
50 char *cursor
= buffer
;
56 union block
*block
= find_next_block ();
61 ERROR ((0, 0, _("Unexpected EOF in mangled names")));
64 available
= available_space_after (block
);
67 memcpy (copy
, block
->buffer
, (size_t) available
);
70 set_next_block_after ((union block
*) (block
->buffer
+ available
- 1));
79 next_cursor
= strchr (cursor
, '\n');
80 *next_cursor
++ = '\0';
82 if (!strncmp (cursor
, "Rename ", 7))
86 name_end
= strchr (name
, ' ');
87 while (strncmp (name_end
, " to ", 4))
90 name_end
= strchr (name_end
, ' ');
93 if (next_cursor
[-2] == '/')
94 next_cursor
[-2] = '\0';
95 unquote_string (name_end
+ 4);
96 if (rename (name
, name_end
+ 4))
97 ERROR ((0, errno
, _("Cannot rename %s to %s"), name
, name_end
+ 4));
98 else if (verbose_option
)
99 WARN ((0, 0, _("Renamed %s to %s"), name
, name_end
+ 4));
102 else if (!strncmp (cursor
, "Symlink ", 8))
105 name_end
= strchr (name
, ' ');
106 while (strncmp (name_end
, " to ", 4))
109 name_end
= strchr (name_end
, ' ');
112 unquote_string (name
);
113 unquote_string (name_end
+ 4);
114 if (symlink (name
, name_end
+ 4)
115 && (unlink (name_end
+ 4) || symlink (name
, name_end
+ 4)))
116 ERROR ((0, errno
, _("Cannot symlink %s to %s"),
117 name
, name_end
+ 4));
118 else if (verbose_option
)
119 WARN ((0, 0, _("Symlinked %s to %s"), name
, name_end
+ 4));
123 ERROR ((0, 0, _("Unknown demangling command %s"), cursor
));
125 cursor
= next_cursor
;
This page took 0.040276 seconds and 5 git commands to generate.