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 about the buf parameter and the size parameter is provided here. For more information about 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. The space that buf refers to should be large enough to contain both the Qlg_Path_Name_T structure and the path name characters themselves. For more information about the Qlg_Path_Name_T structure, see Path name format.

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

Related Information


Example

The following example determines the current directory.

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

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

main()
{
  typedef struct pnstruct
  {
    Qlg_Path_Name_T pathHeader;
    char pathChars[1024];  /* This size must be large enough */
                           /* to contain the path name.      */
  };

  struct pnstruct pathCd;
  struct pnstruct pathCwd;

  char *myPath = "/testDir";

  /***************************************************************/
  /*   Initialize Qlg_Path_Name_T parameters                     */
  /***************************************************************/
  memset(&pathCd, 0, sizeof(pathCd));
  pathCd.pathHeader.CCSID = 37;
  memcpy(pathCd.pathHeader.Country_ID,"US",2);
  memcpy(pathCd.pathHeader.Language_ID,"ENU",3);
  pathCd.pathHeader.Path_Type = QLG_CHAR_SINGLE;
  pathCd.pathHeader.Path_Length = strlen(myPath);
  pathCd.pathHeader.Path_Name_Delimiter[0] = '/';
  memcpy(pathCd.pathChars,
         myPath,
         pathCd.pathHeader.Path_Length);

  if (QlgChdir((Qlg_Path_Name_T *)&pathCd) != 0)
  {
    perror("QlgChdir() error()");
  }
  else
  {
    if (QlgGetcwd((Qlg_Path_Name_T *)&pathCwd,
                  sizeof(pathCwd)) == NULL)
    {
      perror("QlgGetcwd() error");
    }
    else
    {
      printf("QlgGetcwd() was successful.");
    }
  }
}

Output:

QlgGetcwd() was successful.

API introduced: V5R1

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