freebsd-dev/gnu/libexec/uucp/libunix/cwd.c

59 lines
1.4 KiB
C
Raw Normal View History

1993-08-05 18:28:27 +00:00
/* cwd.c
Routines dealing with the current working directory. */
#include "uucp.h"
#include "uudefs.h"
#include "sysdep.h"
#include "system.h"
/* See whether running this file through zsysdep_add_cwd would require
knowing the current working directory. This is used to avoid
determining the cwd if it will not be needed. */
boolean
fsysdep_needs_cwd (zfile)
const char *zfile;
{
return *zfile != '/' && *zfile != '~';
}
/* Expand a local file, putting relative pathnames in the current
working directory. Note that ~/file is placed in the public
directory, rather than in the user's home directory. This is
consistent with other UUCP packages. */
char *
1994-05-07 18:14:43 +00:00
zsysdep_local_file_cwd (zfile, zpubdir, pfbadname)
1993-08-05 18:28:27 +00:00
const char *zfile;
const char *zpubdir;
1994-05-07 18:14:43 +00:00
boolean *pfbadname;
1993-08-05 18:28:27 +00:00
{
1994-05-07 18:14:43 +00:00
if (pfbadname != NULL)
*pfbadname = FALSE;
1993-08-05 18:28:27 +00:00
if (*zfile == '/')
return zbufcpy (zfile);
else if (*zfile == '~')
1994-05-07 18:14:43 +00:00
return zsysdep_local_file (zfile, zpubdir, pfbadname);
1993-08-05 18:28:27 +00:00
else
return zsysdep_add_cwd (zfile);
1995-05-30 05:05:38 +00:00
}
1993-08-05 18:28:27 +00:00
/* Add the current working directory to a remote file name. */
char *
zsysdep_add_cwd (zfile)
const char *zfile;
{
if (*zfile == '/' || *zfile == '~')
return zbufcpy (zfile);
if (zScwd == NULL)
{
ulog (LOG_ERROR, "Can't determine current directory");
return NULL;
}
return zsysdep_in_dir (zScwd, zfile);
}