version 1.70, 2006/04/03 00:40:56 |
version 1.71, 2006/05/03 21:15:59 |
|
|
make_file_list(char *buf) |
make_file_list(char *buf) |
{ |
{ |
char *dir, *file, *cp; |
char *dir, *file, *cp; |
int len, preflen, ret; |
size_t len, preflen; |
|
int ret; |
DIR *dirp; |
DIR *dirp; |
struct dirent *dent; |
struct dirent *dent; |
struct list *last, *current; |
struct list *last, *current; |
|
|
/* first we get a directory name we can look up */ |
/* first we get a directory name we can look up */ |
/* |
/* |
* Names ending in . are potentially odd, because adjustname will |
* Names ending in . are potentially odd, because adjustname will |
* treat foo/.. as a reference to another directory, whereas we are |
* treat foo/bar/.. as a foo/, whereas we are |
* interested in names starting with .. |
* interested in names starting with .. |
*/ |
*/ |
len = strlen(buf); |
len = strlen(buf); |
if (buf[len - 1] == '.') { |
if (len && buf[len - 1] == '.') { |
buf[len - 1] = 'x'; |
buf[len - 1] = 'x'; |
dir = adjustname(buf); |
dir = adjustname(buf); |
buf[len - 1] = '.'; |
buf[len - 1] = '.'; |
|
|
* If the user typed a trailing / or the empty string |
* If the user typed a trailing / or the empty string |
* he wants us to use his file spec as a directory name. |
* he wants us to use his file spec as a directory name. |
*/ |
*/ |
if (buf[0] && buf[strlen(buf) - 1] != '/') { |
if (len && buf[len - 1] != '/') { |
file = strrchr(dir, '/'); |
file = strrchr(dir, '/'); |
if (file) { |
if (file) { |
*file = '\0'; |
*file = '\0'; |
|
|
* SV files are fairly short. For BSD, something more general would |
* SV files are fairly short. For BSD, something more general would |
* be required. |
* be required. |
*/ |
*/ |
if ((preflen + MAXNAMLEN) > NFILEN) |
if (preflen > NFILEN - MAXNAMLEN) |
return (NULL); |
return (NULL); |
|
|
/* loop over the specified directory, making up the list of files */ |
/* loop over the specified directory, making up the list of files */ |