#include <unistd.h> Qlg_Path_Name_T *QlgGetcwd(Qlg_Path_Name_T *buf, size_t size);Service Program Name: QP0LLIB2
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.
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."); } } }
QlgGetcwd() was successful.