Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/u/utime.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/u/utime.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/u/utime.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/u/utime.html on line 8

utime()

Record the modification time for a file or directory

Synopsis:

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

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

int utime( const char* path,
           const struct utimbuf* times );

Arguments:

path
The path name for the file whose modification time you want to get or set.
times
NULL, or a pointer to a utimbuf structure where the function can store the modification time.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The utime() function records the modification time for the file or directory identified by path.

If the times argument is NULL, the access and modification times of the file or directory are set to the current time. The effective user ID of the process must match the owner of the file or directory, or the process must have write permission to the file or directory, or appropriate privileges in order to use the utime() function in this way.

If the times argument isn't NULL, its interpreted as a pointer to a utimbuf structure, and the access and modification times of the file or directory are set to the values contained in the designated structure. Only the owner of the file or directory, and processes with appropriate privileges are permitted to use the utime() function in this way. The access and modification times are taken from the actime and modtime fields in this structure.

Returns:

0
Success.
-1
An error occurred; errno is set.

Errors:

EACCES
Search permission is denied for a component of path, or the times argument is NULL, and the effective user ID of the process doesn't match the owner of the file, and write access is denied.
ENAMETOOLONG
The argument path exceeds PATH_MAX in length, or a pathname component is longer than NAME_MAX.
ENOENT
The specified path doesn't exist, or path is an empty string.
ENOTDIR
A component of path isn't a directory.
EPERM
The times argument isn't NULL, and the calling process's effective user ID has write access to the file but doesn't match the owner of the file, and the calling process doesn't have the appropriate privileges.
EROFS
The named file resides on a read-only filesystem.

Examples:

#include <stdio.h>
#include <stdlib.h>
#include <utime.h>

int main( int argc, char *argv[] )
  {
    if( (utime( argv[1], NULL ) != 0) && (argc > 1) ) {
       printf( "Unable to set time for %s\n", argv[1] );
    }
    return EXIT_SUCCESS;
  }

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

errno, futime()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/u/utime.html on line 215

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/u/utime.html on line 215