system_utime(3f) - [M_system:FILE_SYSTEM] set file access and modification times (LICENSE:PD)
Synopsis
Description
Options
Return Value
Errors
Examples
function utime(pathname,times)
character(len=*),intent(in) :: pathname integer,intent(in),optional :: times(2) logical :: utime
The system_utime(3f) function sets the access and modification times of the file named by the path argument by calling utime(3c).If times() is not present the access and modification times of the file shall be set to the current time.
To use system_utime(3f) the effective user ID of the process must match the owner of the file, or the process has to have write permission to the file or have appropriate privileges,
times If present, the values will be interpreted as the access and modification times as Unix Epoch values. That is, they are times measured in seconds since the Unix Epoch. pathname name of the file whose access and modification times are to be updated.
Upon successful completion .TRUE. is returned. Otherwise, [char46]FALSE. is returned and errno shall be set to indicate the error, and the file times remain unaffected.
The underlying utime(3c) function fails if:
EACCES Search permission is denied by a component of the path prefix; or the times argument is a null pointer and the effective user ID of the process does not match the owner of the file, the process does not have write permission for the file, and the process does not have appropriate privileges. ELOOP A loop exists in symbolic links encountered during resolution of the path argument. ENAMETOOLONG The length of a component of a pathname is longer than {NAME_MAX}. ENOENT A component of path does not name an existing file or path is an empty string. ENOTDIR A component of the path prefix names an existing file that is neither a directory nor a symbolic link to a directory, or the path argument contains at least one non-<slash> character and ends with one or more trailing <slash> characters and the last pathname component names an existing file that is neither a directory nor a symbolic link to a directory. EPERM The times argument is not a null pointer and the effective user ID of the calling process does not match the owner of the file and the calling process does not have appropriate privileges. EROFS The file system containing the file is read-only.
The utime() function may fail if:
ELOOP More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the path argument.ENAMETOOLONG The length of a pathname exceeds {PATH_MAX}, or pathname resolution of a symbolic link produced an intermediate result with a length that exceeds {PATH_MAX}.
Sample program
program demo_system_utime use M_system, only : system_utime, system_perror implicit none character(len=4096) :: pathname integer :: times(2) integer :: i do i=1,command_argument_count() call get_command_argument(i, pathname) if(.not.system_utime(pathname,times))then call system_perror(*demo_system_utime*) endif enddo end program demo_system_utime
Nemo Release 3.1 | system_utime (3m_system) | March 07, 2025 |