Results 1 to 4 of 4

Thread: file date

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    Code:
    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
    Matt

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The example program stat.c from MS should help:
    Code:
    /* 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 ) );
       }
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    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
    Matt

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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)
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width