Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6907657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:27:46+00:00 2026-05-27T08:27:46+00:00

I have a tar file I want to extract with libarchive to a specific

  • 0

I have a tar file I want to extract with libarchive to a specific directory. How can I make libarchive extract into to any directory I want? At the moment it always extracts into my program’s working directory. I looked at this answer but all this does is change the location of an archive entry within the archive, i.e. it still extracts into my program’s working directory just at a different sub-directory.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:27:46+00:00Added an answer on May 27, 2026 at 8:27 am

    From the libarchive discussion boards:

    "It depends, of course, on the archive being extracted.

    Typically, you would chdir() to the directory where you want the output to go, then use code similar to that in the Wiki Examples page:

    A Complete Extractor Example

    or in the untar.c sample program:

    untar Example

    Of course, if the tar file you’re extracting has
    interesting filenames (such as "c:\someotherdirectory"),
    then you’ll need to play with the filenames as you extract.

    Note that the examples all use archive_read_next_header()
    to get an entry object from the input archive describing
    the next entry; you are then free to edit that entry description
    in any way you wish — in particular, you can change the
    name, owner, or permissions — before calling
    archive_write_header() to recreate the entry on
    disk.

    The Examples page in the Wiki above is probably the
    best place to start."

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Premise I have a directory /foo/bar I have a tar file containing the directory
How can we GZip every file separately? I don't want to have all of
I have a huge gzipped tar archive file huge.tar.gz from which I want to
Current Process: I have a tar.gz file. (Actually, I have about 2000 of them,
I have written a shellscript which tries to pull a tar file from an
I have a file src.tar.gz whoes owner and group are named src. When I
I have a tarred gunzip file called ZippedXmls.tar.gz which has 2 xmls inside it.
How do I install xf86-input-synaptics-1.5.99.901-2-x86_64.pkg.tar.xz in ubuntu 11 ? I have found the file
Can you have tar travel to a certain direct and then tar files relative
Suppose I have a tar that contains: / # Root directory /level1/ # A

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.