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 - <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 utimebuf  *times;                Pointer to stored time values

    utime() sets the modification time for the file specified by
    'pathname'.  The file must have write permission.  If 'times' is a
    NULL pointer, the modification time is set to the current time.
    Otherwise, 'times' must point to a structure of type 'utimebuf'
    (defined in <sys\utime.h>). The modification time is set from the
    'modtime' field in 'utimebuf' structure.

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

                    EACCES        Pathname is directory or read only file
                    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 'utimebuf' structure.

  -------------------------------- 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