The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Delete the last modified file kingofprussia UNIX for Dummies Questions & Answers 1 06-04-2008 01:37 PM
how to retrieve original contents of a modified file (modified using vi) novice100 UNIX for Dummies Questions & Answers 3 05-31-2007 05:50 PM
ftp most recently modified file ahmedwaseem2000 Shell Programming and Scripting 6 02-27-2007 09:22 AM
who modified my file!! mohanprabu UNIX for Dummies Questions & Answers 4 10-28-2005 07:18 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-14-2003
Registered User
 

Join Date: Oct 2003
Location: Jerusalem
Posts: 12
File last modified

I cannot read the last moment
the file was modified - it returns
"Most recent access" instead:
code:
</td>
<th><?FILE *fatr=fopen(iindname.c_str(), "r");
if(fatr){
struct stat statbuf;
fstat(fileno(fatr), &statbuf);
fclose(fatr);
?>
<?if(statbuf.st_size>1024)cout<<(statbuf.st_size/1024)<<" K";
else cout << statbuf.st_size?>
</th><th>
<? if (statbuf.st_mode & S_IREAD){?> r <?}
if (statbuf.st_mode & S_IWRITE){?> w <?}?>
</th><th>
<b><?=ctime(&statbuf.st_ctime)?></b>
Is there any other (more sure) method
to do this in C/C++?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-14-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,453
I'm not sure what that gibberish is. Some sort of scripting language based on c++?

But try using st_mtime instead of st_ctime.
Reply With Quote
  #3 (permalink)  
Old 10-14-2003
Registered User
 

Join Date: Oct 2003
Location: Jerusalem
Posts: 12
Quote:
I'm not sure what that gibberish is. Some sort of scripting language based on c++?
No, this is native C/C++ - HTML-embedded (it is transcoded
to real C++ and compiled by common g++ - see preprocessor here -
now I try to crossplatform it )

Quote:
But try using st_mtime instead of st_ctime
it does't help - all three vars (st_mtime, st_ctime and st_atime)
have the same values! What can be a problem?
OS is Linux RH9.
Reply With Quote
  #4 (permalink)  
Old 10-14-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,453
Use the ls command on the file in question.

ls -l file # show mtime
ls -lc file # show ctime
ls -lu file # show atime
Reply With Quote
  #5 (permalink)  
Old 11-05-2003
Registered User
 

Join Date: Oct 2003
Location: Jerusalem
Posts: 12
Works!
Thank you!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0