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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:45:46+00:00 2026-05-26T03:45:46+00:00

Possibly this should be on Superuser, but I’m using it in code so thought

  • 0

Possibly this should be on Superuser, but I’m using it in code so thought I’d start here.

My C++ program unzips a .gz file using the “system()” call. (Yes I know it’s taboo, but it was the best of a bad lot when I started this project a while back, and I asked Unzipping a file from C++ on Redhat: alternatives to system() when I thought I’d have the chance to improve it, but I haven’t managed to implement anything yet)

As there is a chance that a file with the same name already exists, the unzip call uses the “-o” modifier to for an over-write.

Is there a way to detect that there has been an overwrite? I am open to alternatives to system() and unzip.


OS: Redhat

Language: C++

IDE: Eclipse

  • 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-26T03:45:47+00:00Added an answer on May 26, 2026 at 3:45 am

    I believe the obvious answer would be to try to detect whether there is a file with the appropriate name on disk before you even run the system command; if a file exists prior to unzipping, then an overwrite will occur. You can easily check whether a file exists by fopening it with a mode of "r" and checking the return value for a valid file handle. (Don’t forget to fclose the file if it does already exist.)

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

Sidebar

Related Questions

This should be a common problem and possibly similar to some question here but
Pylint says W: 6: Using possibly undefined loop variable 'n' ... with this code:
I found that I should be using Reset CSS file for making websites, but
Ok, this is possibly borderline-subjective, but I wonder where one would put a simple
Hopefully this should be an easy answer for someone out there (and possibly a
Possibly this is related to Using a plugin generated with Firebreath in a Firefox
Not sure if this is a SO, SuperUser or ServerFault question, but I just
As the title reads... is this possibly? Workflow should be like: 1.- User is
I'm really sorry to do this, but this problem represents a possibly exploitable security
Can this be done? It seems like this should be possible. In general, I

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.