Qp0lOpen()--Open File


  Syntax
 #include <Qp0lstdi.h>

 int Qp0lOpen(Qlg_Path_Name_T *Path_Name,
 int oflag, . . .);  
  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

  Theadsafe: Conditional;   see Usage Notes for open() API.

The Qp0lOpen() function, similar to the open() function, opens a file and returns a number called a file descriptor. Qp0lOpen() differs from open() in that the Path_Name parameter is a pointer to a Qlg_Path_Name_T structure instead of a pointer to a character string.

Only the Path_Name parameter is described here. For a discussion of the other parameters, authorities required, return values, and related information, see open()--Open File.

Note:: To use this API with large file APIs, you must specify the O_LARGEFILE flag on the oflag parameter.


Parameters

Path_Name
(Input) The path name of the file to be opened. This path name is in the Qlg_Path_Name_T format. For more information on this structure, see Path name format.

Related Information


Example

The following example creates and opens an output file for exclusive access. This program was stored in a source file with CCSID 37, so the constant string "newfile" will be compiled in coded character set identifier (CCSID) 37. Therefore, the country or region and language specified are United States English, and the CCSID specified is 37.

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

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

main()
{
  int fildes;

  const char US_const[3]= "US";
  const char Language_const[4]="ENU";
  const char Path_Name_Del_const[2] = "/";

  struct pnstruct
    {
     Qlg_Path_Name_T  qlg_struct;
     char             pn[7];
    };
  struct pnstruct pns;
  struct pnstruct *pns_ptr = NULL;

  char fn[]="newfile";

  memset((void*)&pns, 0x00, sizeof(struct pnstruct));
  pns.qlg_struct.CCSID = 37;
  memcpy(pns.qlg_struct.Country_ID,US_const,2);
  memcpy(pns.qlg_struct.Language_ID,Language_const,3);;
  pns.qlg_struct.Path_Type = 0;
  pns.qlg_struct.Path_Length = sizeof(fn) - 1;
  memcpy(pns.qlg_struct.Path_Name_Delimiter,
         Path_Name_Del_const,1);
  memcpy(pns.pn,fn,sizeof(fn));

  pns_ptr = &pns;
  if(fildes = Qp0lOpen((Qlg_Path_Name_T *)pns_ptr,
           O_WRONLY|O_CREAT|O_EXCL, S_IRWXU)) == -1)
  {
        perror("Qp0lOpen() error");
  }

}


API introduced: V4R4

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