QlgGetcwd()--Get Current Directory (using NLS-enabled path name)


  Syntax
 #include <unistd.h>

   Qlg_Path_Name_T *QlgGetcwd(Qlg_Path_Name_T *buf,  
   size_t size);

  Service Program Name: QP0LLIB2

  Default Public Authority: *USE

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

The QlgGetcwd() function, like the getcwd() function, determines the absolute path name of the current directory and returns a pointer to it. The difference is that the pointer returned by QlgGetcwd() is a pointer to a Qlg_Path_Name_T structure that holds the absolute path name, while getcwd() returns a pointer to a character string or buffer that contains the null-terminated absolute path name.

Limited information on the buf parameter and on the size parameter is provided here. For more information on the parameters and for a discussion on authorities required, return values, and related information, see getcwd()--Get Current Directory.


Parameters

buf
(Output) A pointer to a Qlg_Path_Name_T structure that holds the absolute path name of the current directory. The path name is not null-terminated within the structure. For more information on the Qlg_Path_Name_T structure, see Path name format.

size
(Input) The number of bytes allocated for buf.

Related Information


Example

See Code disclaimer information for information pertaining to code examples.

The following example determines the current directory:

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

main()
{

 #define mypath_cd "/tmp"

 const char US_const[3]= "US";
 const char Language_const[4]="ENU";
 typedef struct pnstruct
    {
     Qlg_Path_Name_T qlg_struct;
     char pn[1024];  /* This size must be large enough */
                               /* to contain the path name.     */
    };

 struct pnstruct path_cd;
 struct pnstruct path_cwd;

   /***************************************************************/
   /*   Initialize Qlg_Path_Name_T parameters                     */
   /***************************************************************/
  memset((void*)path name_cd, 0x00, sizeof(struct pnstruct));
  path_cd.qlg_struct.CCSID = 37;
  memcpy(path_cd.qlg_struct.Country_ID,US_const,2);
  memcpy(path_cd.qlg_struct.Language_ID,Language_const,3);
  path_cd.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
  path_cd.qlg_struct.Path_Length = sizeof(mypath_cd)-1;
  path_cd.qlg_struct.Path_Name_Delimiter[0] = '/'
  memcpy(path_cd.pn,mypath_cd,sizeof(mypath_cd)-1);

  if (QlgChdir((Qlg_Path_Name_T *)path name_cd) != 0)
    perror("QlgChdir() error()");
  else
  {
    if (QlgGetcwd(Qlg_Path_Name_T *path_cwd,
                                  sizeof(struct pnstruct)) == NULL)
      perror("QlgGetcwd() error");
    else
      printf("Successful change to new current working directory.");
  }
}

Output:

Successful change to new current working directory.

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