QlgChdir()--Change Current Directory (using NLS-enabled path name)


  Syntax
 #include <unistd.h>

 int QlgChdir(const Qlg_Path_Name_T *path);  
  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

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

The QlgChdir() function, like the chdir() function, makes the directory named by path the new current directory. The difference is that the QlgChdir() function takes a pointer to a Qlg_Path_Name_T structure, while chdir() 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 chdir()--Change Current 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 that should become the current directory. 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 uses QlgChdir():

#include <stdio.h>
#include <unistd.h>

main() {
#define mypath "/tmpXXX"
  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 */
                    /* this 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 (QlgChdir((Qlg_Path_Name_T *)&path) != 0)
  {
    printf("QlgChdir() to /tmpXXX failed.");
  }
  else
  {
   printf("QlgChdir() changed the current directory ");
   printf("to '%s'.\n", mypath);
  }
}

Output:

QlgChdir() changed the current directory to '/tmpxxx'.
(or if error, such as path not found: QlgChdir() to /tmpXXX failed.)

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