home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / uucp / Uucp.framework / unix.subproj / cwd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-09  |  1.4 KB  |  59 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, pfbadname)
  28.      const char *zfile;
  29.      const char *zpubdir;
  30.      boolean *pfbadname;
  31. {
  32.   if (pfbadname != NULL)
  33.     *pfbadname = FALSE;
  34.   if (*zfile == '/')
  35.     return zbufcpy (zfile);
  36.   else if (*zfile == '~')
  37.     return zsysdep_local_file (zfile, zpubdir, pfbadname);
  38.   else
  39.     return zsysdep_add_cwd (zfile);
  40. }      
  41.  
  42. /* Add the current working directory to a remote file name.  */
  43.  
  44. char *
  45. zsysdep_add_cwd (zfile)
  46.      const char *zfile;
  47. {
  48.   if (*zfile == '/' || *zfile == '~')
  49.     return zbufcpy (zfile);
  50.  
  51.   if (zScwd == NULL)
  52.     {
  53.       ulog (LOG_ERROR, "Can't determine current directory");
  54.       return NULL;
  55.     }
  56.  
  57.   return zsysdep_in_dir (zScwd, zfile);
  58. }
  59.