<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation"> <title>QlgGetcwd()--Get Current Directory (using NLS-enabled path name)</title> <!-- Begin Header Records --> <!-- All rights reserved. Licensed Materials Property of IBM --> <!-- US Government Users Restricted Rights --> <!-- Use, duplication or disclosure restricted by --> <!-- GSA ADP Schedule Contract with IBM Corp. --> <!-- Change History: --> <!-- file cleaned --> <!-- Created by Yvonne Griffin for V5R1--> <!-- This file has undergone html cleanup June 2002 by JET --> <link rel="stylesheet" type="text/css" href="../rzahg/ic.css"> </head> <body> <!-- End Header Records --><!--Java sync-link--> <script language="Javascript" src="../rzahg/synch.js" type="text/javascript"> </script> <a name="Top_Of_Page"></a> <h2>QlgGetcwd()--Get Current Directory (using NLS-enabled path name)</h2> <div class="box" style="width: 80%;"> <br> Syntax<br> <pre> #include <unistd.h> Qlg_Path_Name_T *QlgGetcwd(Qlg_Path_Name_T <em>*buf</em>, size_t <em>size</em>); </pre> Service Program Name: QP0LLIB2<br> <!-- iddvc RMBR --> <br> Default Public Authority: *USE<br> <!-- iddvc RMBR --> <br> Threadsafe: Conditional; see Usage Notes for <a href="getcwd.htm">getcwd()</a>.<br> <!-- iddvc RMBR --> <br> </div> <p>The <strong>QlgGetcwd()</strong> function, like the <strong> getcwd()</strong> function, determines the absolute path name of the current directory and returns a pointer to it. The difference is that the pointer returned by <strong>QlgGetcwd()</strong> is a pointer to a Qlg_Path_Name_T structure that holds the absolute path name, while <strong>getcwd()</strong> returns a pointer to a character string or buffer that contains the null-terminated absolute path name.</p> <p>Limited information on the <em>buf</em> parameter and on the <em>size</em> parameter is provided here. For more information on the parameters and for a discussion on authorities required, return values, and related information, see <a href="getcwd.htm">getcwd()</a>--Get Current Directory.</p> <br> <h3>Parameters</h3> <dl> <dt><strong><em>buf</em></strong></dt> <dd>(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 <a href="../apiref/pns.htm">Path name format</a>.<br> <br> </dd> <dt><strong><em>size</em></strong></dt> <dd>(Input) The number of bytes allocated for <em>buf</em>.</dd> </dl> <br> <h3>Related Information</h3> <ul> <li><a href="getcwd.htm">getcwd()</a>--Get Current Directory<br> <br> </li> <li><a href="chdiru.htm">QlgChdir()</a>--Change Current Directory (using NLS-enabled path name)</li> </ul> <br> <h3>Example</h3> <p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a> for information pertaining to code examples.</p> <p>The following example determines the current directory:</p> <pre> #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."); } } </pre> <p><strong>Output:</strong></p> <pre> Successful change to new current working directory. </pre> <hr> API introduced: V5R1 <hr> <center> <table cellpadding="2" cellspacing="2"> <tr align="center"> <td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href= "unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td> </tr> </table> </center> </body> </html>