Click to See Complete Forum and Search --> : file date
MPrestonf12
Apr 7th, 2001, 03:51 PM
char buf[25];
char *sztext = itoa(time.dwLowDateTime,buf,25);
fputs(sztext, fp);
I am trying to print the date a file was created but this just prints some garbage. Does anyone know how to do this? thanks
parksie
Apr 7th, 2001, 03:58 PM
The example program stat.c from MS should help:
/* STAT.C: This program uses the _stat function to
* report information about the file named STAT.C.
*/
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
void main( void )
{
struct _stat buf;
int result;
char buffer[] = "A line to output";
/* Get data associated with "stat.c": */
result = _stat( "stat.c", &buf );
/* Check if statistics are valid: */
if( result != 0 )
perror( "Problem getting information" );
else
{
/* Output some of the statistics: */
printf( "File size : %ld\n", buf.st_size );
printf( "Drive : %c:\n", buf.st_dev + 'A' );
printf( "Time modified : %s", ctime( &buf.st_atime ) );
}
}
MPrestonf12
Apr 7th, 2001, 05:25 PM
it seems to work well with one exception. It only prints 1 date for every file. Can't figure out whats determining it. Any idea? Thanks
parksie
Apr 7th, 2001, 05:33 PM
The stat structure:
gid Numeric identifier of group that owns file (UNIX-specific)
st_atime Time of last access of file.
st_ctime Time of creation of file.
st_dev Drive number of the disk containing the file (same as st_rdev).
st_ino Number of the information node (the inode) for the file (UNIX-specific). On UNIX file systems, the inode describes the file date and time stamps, permissions, and content. When files are soft-linked to one another, they share the same inode. The inode, and therefore st_ino, has no meaning in the FAT, HPFS, or NTFS file systems.
st_mode Bit mask for file-mode information. The _S_IFDIR bit is set if path specifies a directory; the _S_IFREG bit is set if path specifies an ordinary file or a device. User read/write bits are set according to the file's permission mode; user execute bits are set according to the filename extension.
st_mtime Time of last modification of file.
st_nlink Always 1 on non-NTFS file systems.
st_rdev Drive number of the disk containing the file (same as st_dev).
st_size Size of the file in bytes; a 64-bit integer for _stati64 and _wstati64
uid Numeric identifier of user who owns file (UNIX-specific)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.