reds has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use Archive::Tar, but it' keeps stopping with the error: "The filename, directory name, or volume label syntax is incorrect."

$TEMP_PATH contains a directory which I'm tring to tar up so that when unpacked a directory identical to the one in $TEMP_PATH is created (i.e. no absolute paths). $dc is the directory character on whatever platform I'm on.

As you can see, I was tyring two ways to use $tar->add_files() - one in a foreach loop, the other just by directly feeding the function the array - but neither work!

Please help!
my @temp_filelist; my $temppath = $TEMP_PATH; $temppath =~ s/\\/\\\\/g; find(\&wanted, $TEMP_PATH); # this is called for each file in $TEMP_PATH sub wanted { my $path = $File::Find::dir; $path =~ s|^$temppath||o; $path =~ s|[\\/]|$dc|g; $path =~ s|^[\\/]||; push @temp_filelist, "$path${dc}$_"; } my $tar = Archive::Tar->new(); foreach (@temp_filelist) { #print "$_\n"; $tar->add_files("$_"); } #$tar->add_files(@temp_filelist); $tar->write("$OUTPUT_FILE.gz",1); @temp_filelist = $tar->list_files();

Replies are listed 'Best First'.
Re: An "it-must-have-a-simple-answer" Archive::Tar question.
by reds (Novice) on Apr 29, 2003 at 21:24 UTC
    To answer my own question, I fixed the input to write() the same way as I had done with $temppath (i.e. s/\\/\\\\/g) and things appear to work correctly now. Everthing except for what appears to be some disrespect for case-sensitivity inside the archive... Dang; I just want to go home!
      Well, it turns out the case sensitivity isn't the problem (it must be WinZip that doesn't do it right) - the problem is that normally when I create a package, I specify:
      --mode=a+rwx --preserve-permissions
      So, the question then becomes, is it possible to specify such permissions on things from within Perl?
        Well, by issuing a chmod to the files before sticking them in the tar package it appears as if I've reached my desired functionality. Sorry to have cluttered up the section with my brain fart questions.