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 9265351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:03:01+00:00 2026-06-18T14:03:01+00:00

I have written a simple piece of code for extracting zip files using unzip.

  • 0

I have written a simple piece of code for extracting zip files using unzip. It works fine when output directory is not set but returns error is directory is set

“Archive: /home/vishvesh.kumar/tempFolder/test.zip checkdir: cannot
create extraction directory: /home/vishvesh.kumar/tempFolder
No such file or directory”

Code:

int main(int argc, char *argv1[])
{
    std::cout << "Creating child process...";
    std::vector<std::string> arguements;

    char* argv[4] = {0};
    argv [0] = "/usr/bin/unzip";
    argv [2] = "/home/vishvesh.kumar/tempFolder/test.zip";
    argv [1] = "-d /home/vishvesh.kumar/tempFolder/";
    argv [3] = NULL;
   createChildProcess(argv);

}


void createChildProcess(char* argv[])
{
    pid_t pid = fork();
    if (pid == -1)
    {
            std::cout << "error creating child process, exiting...";
            exit(1);
    }
    else if (pid == 0)
    { // This is the child process
       std::cout << "This is the child process. About to sleep\n";
       std::cout << "Woke up\n";
       if (execvp(argv[0], argv))
        { // execvp failed
            std::cout << "fatal - execvp failed!";
            exit(1);
        }

     }
    else
    { // This is the parent process.
        std::cout << "This is the parent process\n";
        int status;
        std::cout << " done. PID: " << pid << ".\n";

        double start = 0;
        waitpid(pid, &status, 0); // Wait for program to finish executing.
        double dur = (clock() - start) / CLOCKS_PER_SEC; // Get execution time
        std::cout << "Sad my son died\n";
        std::cout << "Program returned " << WEXITSTATUS(status);
        std::cout << " and lasted " << dur << " seconds.\nPress enter.\n";
        std::cin.get();
    }
}
  • 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-06-18T14:03:03+00:00Added an answer on June 18, 2026 at 2:03 pm
    char* argv[4] = {0};
    argv [0] = "/usr/bin/unzip";
    argv [2] = "/home/vishvesh.kumar/tempFolder/test.zip";
    argv [1] = "-d /home/vishvesh.kumar/tempFolder/";
    argv [3] = NULL;
    

    Should be:

    char* argv[5];
    argv [0] = "/usr/bin/unzip";
    argv [1] = "-d";
    argv [2] = "/home/vishvesh.kumar/tempFolder/";
    argv [3] = "/home/vishvesh.kumar/tempFolder/test.zip";
    argv [4] = NULL;
    

    The way you have it, the parameter to -d is the zip file, since that’s the parameter after the -d. So it tries to create that directory and can’t because it’s a file.

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

Sidebar

Related Questions

I have a simple piece of code written to open a report. Private Sub
I have a simple piece of code written which basically scans through column A,
I have written this simple piece of code : $ch = curl_init(); //Set options
I have a simple plugin system in a piece of code I have written.
I have a problem with a very simple piece of code written in Javascript,
I have written simple code to get content from xml file to php. $xml
I have written a simple web Application which is running(on Tomcat Server) fine on
I have written a simple WCF service that accepts and stores messages. It works
I have written a simple C++ shell program to parse large XML files and
I have written the following piece of code that reads through a given xml-file

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.