QlgCreat()--Create or Rewrite File (using NLS-enabled path name)


  Syntax
 #include <fcntl.h>

 int QlgCreat(Qlg_Path_Name_T *path, mode_t mode);  
  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

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

The QlgCreat() function, like the creat() function, creates a new file or rewrites an existing file so that it is truncated to zero length. The difference is that the QlgCreat() function takes a pointer to a Qlg_Path_Name_T structure, while creat() takes a pointer to a character string. See open()--Open File for more details on how the function call

     QlgCreat(path,mode);
is equivalent to the call
     QlgOpen(path, O_CREAT|O_WRONLY|O_TRUNC, mode);

Limited information on the path parameter is provided here. For more information on the path parameter and for a discussion of other parameters, authorities required, return values, and related information, see creat()--Create or Rewrite File or open()--Open File.


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 to be created or rewritten. For more information on the Qlg_Path_Name_T structure, see Path name format.

Related Information


Example

See Code disclaimer information for information pertaining to code examples.

The following example creates a file:

#include <stdio.h>
#include <fcntl.h>
#include <Qp0lstdi.h>

main() {
  char text[]="This is a test";
  int file_descriptor;
 #define mypath "creat.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 this 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_IRUSR | S_IWUSR)) < 0)
    perror("QlgCreat() error");
  else {
    write(file_descriptor, text, strlen(text));
    close(file_descriptor);
    QlgUnlink((Qlg_Path_Name_T *)&path);
  }
}

API introduced: V5R1
Top | UNIX-Type APIs | APIs by category