QlgUtime_time64()--Set File Access and Modification Times (time64_t enabled and using NLS-enabled path name)


  Syntax
 #include <utime.h>

 int QlgUtime_time64(Qlg_Path_Name_T *path, const struct utimbuf_time64 *times);  
  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes for utime().

The QlgUtime_time64() function, like the utime_time64() function, sets the access and modification times of path to the values in the utimbuf_time64 structure. The difference is that the QlgUtime_time64() function takes a pointer to a Qlg_Path_Name_T structure, while utime_time64() takes a pointer to a character string.

Limited information about the path parameter is provided here. For more information about the path parameter and for a discussion of other parameters, authorities required, return values, and related information, see utime_time64()--Set File Access and Modification Times (time64_t enabled).


Parameters

path
(Input) A pointer to a Qlg_Path_Name_T structure that contains a path name or a pointer to a path name of the file for which the times should be changed. For more information about the Qlg_Path_Name_T structure, see Path name format.

Related Information


Example

The following example uses QlgUtime_time64().

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#define _LARGE_FILE_API

#include <utime.h>
#include <time.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <Qp0lstdi.h>

main() {
  int file_descriptor;
  struct utimbuf_time64 ubuf;
  struct stat64_time64 info;

 #define mypath "utime.file"

  const char US_const[3]= "US";
  const char Language_const[4] ="ENU";
  typedef struct pnstruct
  {
    Qlg_Path_Name_T qlg_struct;
    char pn[100]; /* This array size must be >= the  */
                    /* length of the path name or must */
                    /* be a pointer to the path name.  */
  };
  struct pnstruct path;

   /***************************************************************/
   /*   Initialize Qlg_Path_Name_T parameters                     */
   /***************************************************************/
  memset((void*)&path, 0x00, sizeof(struct pnstruct));
  path.qlg_struct.CCSID = 37;
  memcpy(path.qlg_struct.Country_ID,US_const,2);
  memcpy(path.qlg_struct.Language_ID,Language_const,3);
  path.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
  path.qlg_struct.Path_Length = sizeof(mypath)-1;
  path.qlg_struct.Path_Name_Delimiter[0] = '/';
  memcpy(path.pn,mypath,sizeof(mypath)-1);

  if ((file_descriptor =
       QlgCreat((Qlg_Path_Name_T *)&path, S_IWUSR)) < 0)
    perror("creat() error");
  else {
    close(file_descriptor);
    puts("before QlgUtime_time64()");
    QlgStat64_time64((Qlg_Path_Name_T *)&path,&info);
    printf(" utime.file modification time is %lld\n",
           info.st_mtime);
    ubuf.modtime = 0;       /* set modification time to Epoch */
    time64(&ubuf.actime);
    if (QlgUtime_time64((Qlg_Path_Name_T *)&path, &ubuf) != 0)
      perror("QlgUtime_time64() error");
    else {
      puts("after QlgUtime_time64()");
      QlgStat64_time64((Qlg_Path_Name_T *)&path,&info);
      printf(" utime.file modification time is %lld\n",
             info.st_mtime);
    }
    QlgUnlink((Qlg_Path_Name_T *)&path);
  }
}

Output:

before QlgUtime_time64()
  utime.file modification time is 749323571
after QlgUtime_time64()
  utime.file modification time is 0


API introduced: IBM® i 7.2

[ Back to top | UNIX-Type APIs | APIs by category ]