14.1 Accessing Files on Remote Servers

If your application requires access only to the files on the server that is its host, you can use only standard functions for your file and directory tasks. However, if your application needs access to files on remote servers, you will need to use some Novell and NKS functions. To use these functions, you need to know the following:

To access files on a remote server

  1. Create an identity to the tree for a given user and password.

      rc = create_identity(treeName, userName, password, 0,
           flags, &MyIdentity);
      

    The treeName, userName, and password parameters are strings containing the needed information. The flags parameter indicates the transport type. To use any available transport, set flags to the following:

      flags = XPORT_WILD
      

    For more information on these parameters, see create_identity.

    You use the identity returned in MyIdentity to create a path context.

  2. Create a path context.

      rc = NXCreatePathContext(0, ServerName, 0, (void *)
           MyIdentity, &pathCtx);
      

    The ServerName parameter needs to point to a string containing at least the server name and a volume.

    For more information on these parameters, see AllocateResourceTag and NXCreatePathContext.

    You can use the returned pathCtx with NKS functions (NX ...) to perform file operations or you can use it to set the current working directory and then use POSIX functions for file operations.

  3. Set the current working directory.

      /*For all threads on the VM */
      setcwd(pathCtx)
      
      /*For the current thread */
      setcwd2(pathCtx)