QlgMkdir()--Make Directory (using NLS-enabled path name)


  Syntax
 #include <sys/stat.h>

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

  Default Public Authority: *USE

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

The QlgMkdir() function, like the mkdir() function, creates a new, empty directory whose name is defined by path. The difference is that the QlgMkdir() function takes a pointer to a Qlg_Path_Name_T structure, while mkdir() takes a pointer to a character string.

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 mkdir()--Make Directory.


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

Related Information


Example

The following example creates a new directory.

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

#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
main() {

 #define mypath "new_dir"
  const char US_const[3]= "US";
  const char Language_const[4] ="ENU";
  const char mypath_DOT_DOT[3] = "..";

  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;
  struct pnstruct path_DOT_DOT;

   /***************************************************************/
   /*   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);


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

  if (QlgMkdir((Qlg_Path_Name_T *)&path,
               S_IRWXU|S_IRGRP|S_IXGRP) != 0)
    perror("QlgMkdir() error");
  else if (QlgChdir((Qlg_Path_Name_T *)&path) != 0)
    perror("first QlgChdir() error");
  else if (QlgChdir((Qlg_Path_Name_T *)&path_DOT_DOT) != 0)
    perror("second QlgChdir() error");
  else if (QlgRmdir((Qlg_Path_Name_T *)&path) != 0)
    perror("QlgRmdir() error");
  else
    puts("success!");
}

API introduced: V5R1

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