Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>utime() set file-modification time</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 utime()                 Set File-Modification Time

 #include   <sys\types.h>
 #include   <sys\utime.h>

 int              utime(pathname,times);
 char             *pathname;             File path name
 struct utimbuf   *times;                Pointer to stored time values

    utime() sets the time of last modification for the file specified by
    'pathname'.  The file cannot be read-only; it must have write
    permission.  If 'times' is a NULL pointer, the time of last
    modification is set to the current time. If 'times' is not a NULL
    pointer, it must point to a structure of type 'utimbuf' (defined in
    <sys\utime.h>), which stores the following values:

     struct utimbuf {
          time_t    actime;        /*access time*/
          time_t    modtime;       /*modification time*/
     };

    The modification time is set from the 'modtime' field.

    Returns:    Zero if the file modification time was changed.  On
                error, -1 is returned and 'errno' (defined in <stdlib.h>)
                is set to one of the following:

                    EACCES        Pathname is directory or read only file
                    EINVAL        The 'times' argument is invalid.
                    EMFILE        Too many open files.
                    ENOENT        File or path name not found.

      Notes:    Under MS-DOS, only the modification time can be set
                through the 'utimbuf' structure.

 Portability:   Not supported by ANSI standard.

   -------------------------------- Example ---------------------------------

    The following statement sets the file modification time to the
    current time.

           #include <sys\types.h>
           #include <sys\utime.h>
           #include <stdio.h>                 /* for fopen */
           #include <stdlib.h>                /* for perror */

           FILE *stream;

           main()
           {
              if ((stream = fopen("input.dat","r+")) != NULL) {
                     if (utime("input.dat",NULL) == -1)
                         printf("unable to change modification time");
              }
           }


See Also: asctime() ctime() fstat() gmtime() localtime()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson