home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / uucp-1.04 / unix / cwd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-13  |  1.3 KB  |  56 lines

  1. /* cwd.c
  2.    Routines dealing with the current working directory.  */
  3.  
  4. #include "uucp.h"
  5.  
  6. #include "uudefs.h"
  7. #include "sysdep.h"
  8. #include "system.h"
  9.  
  10. /* See whether running this file through zsysdep_add_cwd would require
  11.    knowing the current working directory.  This is used to avoid
  12.    determining the cwd if it will not be needed.  */
  13.  
  14. boolean
  15. fsysdep_needs_cwd (zfile)
  16.      const char *zfile;
  17. {
  18.   return *zfile != '/' && *zfile != '~';
  19. }
  20.  
  21. /* Expand a local file, putting relative pathnames in the current
  22.    working directory.  Note that ~/file is placed in the public
  23.    directory, rather than in the user's home directory.  This is
  24.    consistent with other UUCP packages.  */
  25.  
  26. char *
  27. zsysdep_local_file_cwd (zfile, zpubdir)
  28.      const char *zfile;
  29.      const char *zpubdir;
  30. {
  31.   if (*zfile == '/')
  32.     return zbufcpy (zfile);
  33.   else if (*zfile == '~')
  34.     return zsysdep_local_file (zfile, zpubdir);
  35.   else
  36.     return zsysdep_add_cwd (zfile);
  37. }      
  38.  
  39. /* Add the current working directory to a remote file name.  */
  40.  
  41. char *
  42. zsysdep_add_cwd (zfile)
  43.      const char *zfile;
  44. {
  45.   if (*zfile == '/' || *zfile == '~')
  46.     return zbufcpy (zfile);
  47.  
  48.   if (zScwd == NULL)
  49.     {
  50.       ulog (LOG_ERROR, "Can't determine current directory");
  51.       return NULL;
  52.     }
  53.  
  54.   return zsysdep_in_dir (zScwd, zfile);
  55. }
  56.