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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:27:26+00:00 2026-05-18T06:27:26+00:00

In my C/C++ program I need to check if the file from what I

  • 0

In my C/C++ program I need to check if the file from what I read have been overwrote (its inode was changed or some new lines were added). If I’m now wrong fstat and fstat64 can be usefull only when I use Linux but not for windows. Is there any universal (to work for complex OSes) way to do this? And also can you tell me how do this using fstat64?

  • 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-18T06:27:26+00:00Added an answer on May 18, 2026 at 6:27 am

    You can keep track of when the file was last written to know if it has been modified. The cross platform solution is using boost::filesystem. Windows doesn’t have fstat64 AFAIK.

    http://www.boost.org/doc/libs/1_44_0/libs/filesystem/v2/doc/index.htm

    http://rosettacode.org/wiki/File_modification_time#C.2B.2B
    
    #include <boost/filesystem/operations.hpp>
    #include <ctime>
    #include <iostream>
    
    int main( int argc , char *argv[ ] ) {
       if ( argc != 2 ) {
          std::cerr << "Error! Syntax: moditime <filename>!\n" ;
          return 1 ;
       }
       boost::filesystem::path p( argv[ 1 ] ) ;
       if ( boost::filesystem::exists( p ) ) {
          std::time_t t = boost::filesystem::last_write_time( p ) ;
          std::cout << "On " << std::ctime( &t ) << " the file " << argv[ 1 ] 
         << " was modified the last time!\n" ;
          std::cout << "Setting the modification time to now:\n" ;
          std::time_t n = std::time( 0 ) ;
          boost::filesystem::last_write_time( p , n ) ; 
          t = boost::filesystem::last_write_time( p ) ;
          std::cout << "Now the modification time is " << std::ctime( &t ) << std::endl ;
          return 0 ;
      } else {
          std::cout << "Could not find file " << argv[ 1 ] << '\n' ;
          return 2 ;
      }
    

    }

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

Sidebar

Related Questions

I have c# program , and one file from where it read-write some info.
My program uses MVC. When the user hits New File, I need to check
I have written a program in Java to read in a text file of
Since I write a command line program to check cpp files, and it need
I'm writing a 'Sudoku' program, and I need to write a method to check
In my program I need to programmatically configure an ApplicationContext. Specifically, I have a
I have a .NET program and a Borland Win32 program that need to pass
I need my program to work only with certain USB Flash drives (from a
I need my program to create and edit a config file, which would contain
I have a program that I need to run under *nix and windows. because

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.