getcwdpath

Returns the current working directory, including NetWare information, of the current thread and, optionally, the path context of the current working directory.

Library:LibC
Classification:Novell
Service:File and Directory I/O

Syntax

  #include <fsio.h>
   
  char *getcwdpath (
     char           *buf,
     NXPathctx_t    *pathCtx,
     unsigned long   flags);
  

Parameters

buf

(IN/OUT) Points to the null-terminated string for the current working directory. Because the maximum length is assumed to be 255 bytes, buf is assumed to be large enough to hold 255 bytes and the null-terminating character. If buf is NULL, the current working directory is not returned.

pathCtx

(IN/OUT) Specifies a location to hold a new path context, which references the same context as the current working directory. If NULL is passed, a path context is not returned.

flags

(IN) Indicates whether to return a copy of the path context or the actual path context. If a copy is returned, the caller must free the context by calling NXFreePathContext. If the actual path context is returned, the caller must not free context because such behavior is undefined and results in unexpected consequences. Use one of the following values:

  • To return a copy of the path context, set flags to 0.

  • To return the actual path context, set flags to CTX_ACTUAL_CWD (0x01).

Return Values

If successful, returns a pointer to a string, which contains the name of the current working directory. Otherwise, returns a NULL pointer and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

The underlying file descriptor is invalid.

5

ENOMEM

Insufficient storage space is available.

6

EACCES

Read or search permission was denied for a component of the path.

105

ENOCONTEXT

The calling thread has no context.

Remarks

The getcwdpath function returns, just as getcwd, the current working directory in string form, but the result is usefully enhanced in two ways:

  • The returned string contains a full NetWare path to the directory, including the volume name (for example, "sys:\public"). If the calling thread has an authenticated connection to the server, the server name is also included (for example, "myserver/sys:\public").

  • If requested, a copy of the underlying NKS path context is returned. This is useful for calling NKS functions such as NXCreatePathContext.

NOTE:If the current working directory is the root of a volume, getcwdpath returns the volume and the backslash. For example: "sys:\"

The type of string returned, whether ASCII or UTF-8, depends upon your application's link flags. The current working directory determines the pathname format.

For the server name to be included in the path string, you must have called create_identity to authenticate to an eDirectory™ tree, called NXCreatePathContext to inject the identity into a path context, and called setcwd or setcwd2 to set the path of the current working directory to that path.

See Also

Example

  #include <unistd.h>
  #include <fsio.h>
  
     NXPathCtx_t   dirH;
     char         *strp;
     char          buf[256];
  
     printf("\ngetcwdpath");
     strp = getcwdpath(buf, &dirH, 0);
     printf(": string=%s, dirH=%d", strp, dirH);
  

If the cwd is sys:\system and the allocated path context handle is the second one, this example would have output similar to the following:

     getcwdpath: string=sys:\system, dirH=2
  

This example does not return the server name because the example does not establish an authenticated connection. If an authenticated connection had been established to myserver, the example would have output similar to the following:

     getcwdpath: string=myserver/sys:\system, dirH=2