*** empty log message ***
This commit is contained in:
parent
5817719a7c
commit
9cab0b0105
|
@ -1,8 +1,9 @@
|
|||
#ifdef BSD4_2
|
||||
#include "/usr/include/sys/dir.h"
|
||||
#define MAXNAMLEN 255
|
||||
#else
|
||||
#define DIRBLKSIZ 512
|
||||
#define MAXNAMLEN 14
|
||||
#endif
|
||||
#define DIRBLKSIZ 512
|
||||
#undef DIRSIZ
|
||||
#define DIRSIZ(dp) \
|
||||
((sizeof(struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1+3)&~3))
|
||||
|
@ -17,7 +18,8 @@ struct _dirdesc {
|
|||
int dd_fd;
|
||||
long dd_loc;
|
||||
long dd_size;
|
||||
char dd_buf[DIRBLKSIZ];
|
||||
char *dd_buf;
|
||||
int dd_bsize;
|
||||
};
|
||||
|
||||
typedef struct _dirdesc DIR;
|
||||
|
@ -25,10 +27,9 @@ typedef struct _dirdesc DIR;
|
|||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
extern DIR *opendir();
|
||||
extern DIR *opendir();
|
||||
extern struct direct *readdir();
|
||||
extern long telldir();
|
||||
extern seekdir();
|
||||
extern long telldir();
|
||||
extern seekdir();
|
||||
#define rewinddir(dirp) seekdir((dirp), 0L)
|
||||
extern closedir();
|
||||
#endif
|
||||
extern closedir();
|
||||
|
|
|
@ -10,5 +10,6 @@ register DIR *dirp;
|
|||
close(dirp->dd_fd);
|
||||
dirp->dd_fd = -1;
|
||||
dirp->dd_loc = 0;
|
||||
free(dirp);
|
||||
free(dirp->dd_buf);
|
||||
free((char *)dirp);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,21 @@ char *name;
|
|||
close (fd);
|
||||
return NULL;
|
||||
}
|
||||
if ((int) stbuf.st_size == stbuf.st_size &&
|
||||
(dirp->dd_buf = malloc((unsigned) stbuf.st_size))) {
|
||||
dirp->dd_bsize = stbuf.st_size;
|
||||
}
|
||||
else if (dirp->dd_buf = malloc(8*DIRBLKSIZ)) {
|
||||
dirp->dd_bsize = 8 * DIRBLKSIZ;
|
||||
}
|
||||
else if (dirp->dd_buf = malloc(DIRBLKSIZ)) {
|
||||
dirp->dd_bsize = DIRBLKSIZ;
|
||||
}
|
||||
else {
|
||||
close(fd);
|
||||
free((char *) dirp);
|
||||
return NULL;
|
||||
}
|
||||
dirp->dd_fd = fd;
|
||||
dirp->dd_loc = 0;
|
||||
return dirp;
|
||||
|
|
|
@ -27,7 +27,7 @@ register DIR *dirp;
|
|||
for (;;) {
|
||||
if (dirp->dd_loc == 0) {
|
||||
dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
|
||||
DIRBLKSIZ);
|
||||
dirp->dd_bsize);
|
||||
if (dirp->dd_size <= 0) {
|
||||
dirp->dd_size = 0;
|
||||
return NULL;
|
||||
|
|
|
@ -16,22 +16,18 @@ long loc;
|
|||
curloc = telldir(dirp);
|
||||
if (loc == curloc)
|
||||
return;
|
||||
base = loc & ~(DIRBLKSIZ - 1);
|
||||
offset = loc & (DIRBLKSIZ - 1);
|
||||
offset = loc % dirp->dd_bsize;
|
||||
base = loc - offset;
|
||||
if (dirp->dd_loc != 0 && offset != 0 &&
|
||||
(curloc & ~(DIRBLKSIZ-1)) == base) {
|
||||
(curloc - (curloc % dirp->dd_bsize)) == base) {
|
||||
dirp->dd_loc = offset;
|
||||
return;
|
||||
}
|
||||
(void) lseek(dirp->dd_fd, base, 0);
|
||||
dirp->dd_loc = 0;
|
||||
dirp->dd_size = 0;
|
||||
if (offset == 0)
|
||||
(void) readdir(dirp);
|
||||
else {
|
||||
while (dirp->dd_loc < offset) {
|
||||
if (readdir(dirp) == (struct direct *) 0)
|
||||
return;
|
||||
}
|
||||
while (dirp->dd_loc < offset) {
|
||||
if (readdir(dirp) == (struct direct *) 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue