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


  Syntax
 #include <utime.h>

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

  Default Public Authority: *USE

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

The QlgUtime() function, like the utime() function, sets the access and modification times of path to the values in the utimbuf structure. The difference is that the QlgUtime() function takes a pointer to a Qlg_Path_Name_T structure, while utime() 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()--Set File Access and Modification Times.


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().

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

#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 ubuf;
  struct stat 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()");
    QlgStat((Qlg_Path_Name_T *)&path,&info);
    printf(" utime.file modification time is %ld\n",
           info.st_mtime);
    ubuf.modtime = 0;       /* set modification time to Epoch */
    time(&ubuf.actime);
    if (QlgUtime((Qlg_Path_Name_T *)&path, &ubuf) != 0)
      perror("QlgUtime() error");
    else {
      puts("after QlgUtime()");
      QlgStat((Qlg_Path_Name_T *)&path,&info);
      printf(" utime.file modification time is %ld\n",
             info.st_mtime);
    }
    QlgUnlink((Qlg_Path_Name_T *)&path);
  }
}

Output:

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

API introduced: V5R1

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