version 1.4, 1996/06/26 05:36:29 |
version 1.5, 1996/09/02 16:04:09 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: dir.c,v 1.10 1996/02/04 22:20:38 christos Exp $ */ |
/* $NetBSD: dir.c,v 1.11 1996/08/13 16:42:02 christos Exp $ */ |
|
|
/* |
/* |
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California. |
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California. |
|
|
(pattern[0] == '.'))) |
(pattern[0] == '.'))) |
{ |
{ |
(void)Lst_AtEnd(expansions, |
(void)Lst_AtEnd(expansions, |
(isDot ? strdup(entry->name) : |
(isDot ? estrdup(entry->name) : |
str_concat(p->name, entry->name, |
str_concat(p->name, entry->name, |
STR_ADDSLASH))); |
STR_ADDSLASH))); |
} |
} |
|
|
} |
} |
hits += 1; |
hits += 1; |
dot->hits += 1; |
dot->hits += 1; |
return (strdup (name)); |
return (estrdup (name)); |
} |
} |
|
|
if (Lst_Open (path) == FAILURE) { |
if (Lst_Open (path) == FAILURE) { |
|
|
/* |
/* |
* Checking in dot -- DON'T put a leading ./ on the thing. |
* Checking in dot -- DON'T put a leading ./ on the thing. |
*/ |
*/ |
file = strdup(name); |
file = estrdup(name); |
checkedDot = TRUE; |
checkedDot = TRUE; |
} |
} |
if (DEBUG(DIR)) { |
if (DEBUG(DIR)) { |
|
|
} |
} |
|
|
if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) { |
if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) { |
return (strdup (name)); |
return (estrdup (name)); |
} else { |
} else { |
return ((char *) NULL); |
return ((char *) NULL); |
} |
} |
|
|
if (DEBUG(DIR)) { |
if (DEBUG(DIR)) { |
printf("got it (in mtime cache)\n"); |
printf("got it (in mtime cache)\n"); |
} |
} |
return(strdup(name)); |
return(estrdup(name)); |
} else if (stat (name, &stb) == 0) { |
} else if (stat (name, &stb) == 0) { |
entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL); |
entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL); |
if (DEBUG(DIR)) { |
if (DEBUG(DIR)) { |
|
|
name); |
name); |
} |
} |
Hash_SetValue(entry, (long)stb.st_mtime); |
Hash_SetValue(entry, (long)stb.st_mtime); |
return (strdup (name)); |
return (estrdup (name)); |
} else { |
} else { |
if (DEBUG(DIR)) { |
if (DEBUG(DIR)) { |
printf("failed. Returning NULL\n"); |
printf("failed. Returning NULL\n"); |
|
|
} |
} |
|
|
if (fullName == (char *)NULL) { |
if (fullName == (char *)NULL) { |
fullName = strdup(gn->name); |
fullName = estrdup(gn->name); |
} |
} |
|
|
entry = Hash_FindEntry(&mtimes, fullName); |
entry = Hash_FindEntry(&mtimes, fullName); |
|
|
|
|
if ((d = opendir (name)) != (DIR *) NULL) { |
if ((d = opendir (name)) != (DIR *) NULL) { |
p = (Path *) emalloc (sizeof (Path)); |
p = (Path *) emalloc (sizeof (Path)); |
p->name = strdup (name); |
p->name = estrdup (name); |
p->hits = 0; |
p->hits = 0; |
p->refCount = 1; |
p->refCount = 1; |
Hash_InitTable (&p->files, -1); |
Hash_InitTable (&p->files, -1); |
|
|
LstNode ln; /* the node of the current directory */ |
LstNode ln; /* the node of the current directory */ |
Path *p; /* the structure describing the current directory */ |
Path *p; /* the structure describing the current directory */ |
|
|
str = strdup (""); |
str = estrdup (""); |
|
|
if (Lst_Open (path) == SUCCESS) { |
if (Lst_Open (path) == SUCCESS) { |
while ((ln = Lst_Next (path)) != NILLNODE) { |
while ((ln = Lst_Next (path)) != NILLNODE) { |