Tar on Windows XP

Discussion in 'Perl Misc' started by David Walker, Jan 29, 2007.

  1. David Walker

    David Walker Guest

    Hi

    I am trying to create a tar archive on Windows XP with the Perl code below.
    However, when I look at the archive created (using WinZip 10.0) all the
    directory information is lost, and when I untar it using WinZip all I get is
    all the files in the same directory. Can some kind person please tell me how
    I can create the tar file so that when it is untar'd the directory
    structure will be preserved.

    Thanks
    David

    use Archive::Tar;
    use IO::Zlib;
    use File::Find;

    $dir = "c:/docume~1/david/somedir";
    $archive = "c:/docume~1/david/archive.tar";
    $tar = Archive::Tar->new;

    (@files);
    find(\&wanted, $dir);
    $tar->add_files(@files);
    $tar->write($archive);

    sub wanted{
    push(@files,$File::Find::name);
    }
    David Walker, Jan 29, 2007
    #1
    1. Advertising

  2. David Walker

    Sisyphus Guest

    "David Walker" <> wrote in message
    news:Gxuvh.18350$...
    > Hi
    >
    > I am trying to create a tar archive on Windows XP with the Perl code
    > below. However, when I look at the archive created (using WinZip 10.0) all
    > the directory information is lost, and when I untar it using WinZip all I
    > get is all the files in the same directory. Can some kind person please
    > tell me how I can create the tar file so that when it is untar'd the
    > directory structure will be preserved.
    >


    From the "FAQ" section in 'perldoc Archive::Tar' :

    -- quote --
    I'm using WinZip, or some other non-POSIX client, and files are not
    being extracted properly!
    By default, "Archive::Tar" is in a completely POSIX-compatible mode,
    which uses the POSIX-specification of "tar" to store files. For
    paths greather than 100 characters, this is done using the "POSIX
    header prefix". Non-POSIX-compatible clients may not support this
    part of the specification, and may only support the "GNU Extended
    Header" functionality. To facilitate those clients, you can set the
    $Archive::Tar::DO_NOT_USE_PREFIX variable to "true". See the "GLOBAL
    VARIABLES" section for details on this variable.
    -- end quote --

    Hopefully, that deals with the problem you're facing. (If not, let us know -
    and also tell us which version of Archive::Tar you have.).)

    Cheers,
    Rob
    Sisyphus, Jan 30, 2007
    #2
    1. Advertising

  3. David Walker

    David Walker Guest

    Rob

    Yes that worked! I was using Tar 1.07, which didn't have the
    DO_NOT_USE_PREFIX feature, so I've now installed Tar 1.30.

    Thanks for your help.

    David

    "Sisyphus" <> wrote in message
    news:45bec765$0$9776$...
    >
    > "David Walker" <> wrote in message
    > news:Gxuvh.18350$...
    >> Hi
    >>
    >> I am trying to create a tar archive on Windows XP with the Perl code
    >> below. However, when I look at the archive created (using WinZip 10.0)
    >> all the directory information is lost, and when I untar it using WinZip
    >> all I get is all the files in the same directory. Can some kind person
    >> please tell me how I can create the tar file so that when it is untar'd
    >> the directory structure will be preserved.
    >>

    >
    > From the "FAQ" section in 'perldoc Archive::Tar' :
    >
    > -- quote --
    > I'm using WinZip, or some other non-POSIX client, and files are not
    > being extracted properly!
    > By default, "Archive::Tar" is in a completely POSIX-compatible
    > mode,
    > which uses the POSIX-specification of "tar" to store files. For
    > paths greather than 100 characters, this is done using the "POSIX
    > header prefix". Non-POSIX-compatible clients may not support this
    > part of the specification, and may only support the "GNU Extended
    > Header" functionality. To facilitate those clients, you can set the
    > $Archive::Tar::DO_NOT_USE_PREFIX variable to "true". See the
    > "GLOBAL
    > VARIABLES" section for details on this variable.
    > -- end quote --
    >
    > Hopefully, that deals with the problem you're facing. (If not, let us
    > know - and also tell us which version of Archive::Tar you have.).)
    >
    > Cheers,
    > Rob
    >
    David Walker, Jan 30, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Claudio Grondi
    Replies:
    4
    Views:
    553
    Claudio Grondi
    Aug 20, 2005
  2. Replies:
    2
    Views:
    424
    Michael Hoffman
    Apr 24, 2007
  3. Ray Van Dolson
    Replies:
    0
    Views:
    321
    Ray Van Dolson
    Sep 23, 2009
  4. Ray Van Dolson
    Replies:
    0
    Views:
    824
    Ray Van Dolson
    Sep 25, 2009
  5. benoit Guyon
    Replies:
    2
    Views:
    218
    benoit Guyon
    Jul 26, 2005
Loading...

Share This Page