Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-01-2002, 06:43 AM   #1
Member (4 bit)
 
Join Date: Mar 2002
Location: London
Posts: 9
Pissed windows timestamps

Please could someone tell me how to access the time details of a file. THese canbe seen in any file by rightclicking on the icon and selecting properties. THe times displayed are "created" and "modified". FOr my dissertation i have to create a C: program that checks to see if these two times are identicle. if not the program suggests the program has been altered. Does anyone know how to point to these times? please help, just weeks left!!!!!
comfort_17 is offline   Reply With Quote
Old 03-01-2002, 09:43 AM   #2
Member (5 bit)
 
Join Date: Mar 2001
Posts: 17
You need to use a function called _fstat. Do you have access to MSDN. This will give you a full explanation on how to use this function. I've pasted in a copy of the example which is included in the help. This reports the size and modification time. I'm sure you can modify this to report the info you need. Other parameters stored in the structure returned include:

st_atime

Time of last file access.

st_ctime

Time of creation of file.

st_dev

If a device, handle; otherwise 0.

st_mode

Bit mask for file-mode information. The _S_IFCHR bit is set if handle refers to a device. The _S_IFREG bit is set if handle refers to an ordinary file. The read/write bits are set according to the file’s permission mode. _S_IFCHR and other constants are defined in SYS\STAT.H.

st_mtime

Time of last modification of file.

st_nlink

Always 1 on non-NTFS file systems.

st_rdev

If a device, handle; otherwise 0.

st_size

Size of the file in bytes.


/* FSTAT.C: This program uses _fstat to report
* the size of a file named F_STAT.OUT.
*/

#include
#include
#include
#include
#include
#include
#include
#include

void main( void )
{
struct _stat buf;
int fh, result;
char buffer[] = "A line to output";

if( (fh = _open( "f_stat.out", _O_CREAT | _O_WRONLY |
_O_TRUNC )) == -1 )
_write( fh, buffer, strlen( buffer ) );

/* Get data associated with "fh": */
result = _fstat( fh, &buf );

/* Check if statistics are valid: */
if( result != 0 )
printf( "Bad file handle\n" );
else
{
printf( "File size : %ld\n", buf.st_size );

printf( "Time modified : %s", ctime( &buf.st_ctime ) );
}
_close( fh );
}


Output

File size : 0
Time modified : Tue Mar 21 15:23:08 1995
DrPC is offline   Reply With Quote
Old 03-01-2002, 09:48 AM   #3
Member (5 bit)
 
Join Date: Mar 2001
Posts: 17
Sorry, seem to have lost the include's on the past:

io.h
fcntl.h
time.h
sys/types.h
sys/stat.h
stdio.h
stdlib.h
string.h
DrPC is offline   Reply With Quote
Old 03-05-2002, 07:06 AM   #4
Member (4 bit)
 
Join Date: Mar 2002
Location: London
Posts: 9
MSDN?

Sorry, i dont know what MSDN is. could you email me the details of this direct to comfort_17@yahoo.com
comfort_17 is offline   Reply With Quote
Old 03-05-2002, 07:31 AM   #5
Member (10 bit)
 
Join Date: Apr 2001
Location: Michigan
Posts: 850
Send a message via ICQ to HackinCowboy
MSDN = Microsoft Developer Network
It's basically a really big tutorial. Very helpful. You can search for any function, property, or pretty much anything having to do with languagues offered in Visual Studio.
http://msdn.microsoft.com/
HackinCowboy is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:52 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2