blob: 3beae679f2bf7df635236ca5364d058d7c3820ca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/
#include <stdio.h>
#define import_kernel
#define import_knames
#define import_spp
#include <iraf.h>
extern char oscwd[];
/* ZFCHDR -- Change the current working directory. Save directory name,
* excluding the trailing "/", in oscwd so that a subsequent call to ZFGCWD
* will be able to return directory name without a big hassle.
*/
int
ZFCHDR (
PKCHAR *newdir,
XINT *status
)
{
register char *ip, *op;
char dirname[SZ_PATHNAME];
/* Change pathnames like "a/b/c/" to "a/b/c".
*/
for (ip=(char *)newdir, op=dirname; (*op = *ip++) != EOS; op++)
;
if ((*(op-1) == '/') && (op - dirname > 1))
*(op-1) = EOS;
/* Ask UNIX to change the cwd to newdir.
*/
if (chdir (dirname) == ERR) {
*status = XERR;
} else if (dirname[0] == '/') {
/* Save pathname of directory.
*/
strcpy (oscwd, dirname);
*status = XOK;
} else {
/* Concatenate subdir name to current directory pathname.
*/
for (op=oscwd; *op; op++)
;
if (*(op-1) != '/')
*op++ = '/';
for (ip=dirname; (*op++ = *ip++); )
;
}
return (*status);
}
|