mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-05 12:12:28 +00:00
Fix some bugs
This commit is contained in:
parent
5584f6adcf
commit
6c0bbfac4a
15 changed files with 289 additions and 136 deletions
56
third_party/unzip/unix.c
vendored
56
third_party/unzip/unix.c
vendored
|
@ -133,62 +133,6 @@ static ZCONST char CannotSetTimestamps[] =
|
|||
|
||||
|
||||
#ifndef SFX
|
||||
#ifdef NO_DIR /* for AT&T 3B1 */
|
||||
|
||||
#define _opendir(path) fopen(path,"r")
|
||||
#define _closedir(dir) fclose(dir)
|
||||
typedef FILE DIR;
|
||||
typedef struct zdir {
|
||||
FILE *dirhandle;
|
||||
struct dirent *entry;
|
||||
} DIR
|
||||
DIR *opendir OF((ZCONST char *dirspec));
|
||||
void closedir OF((DIR *dirp));
|
||||
struct dirent *readdir OF((DIR *dirp));
|
||||
|
||||
DIR *opendir(dirspec)
|
||||
ZCONST char *dirspec;
|
||||
{
|
||||
DIR *dirp;
|
||||
|
||||
if ((dirp = malloc(sizeof(DIR)) != NULL) {
|
||||
if ((dirp->dirhandle = fopen(dirspec, "r")) == NULL) {
|
||||
free(dirp);
|
||||
dirp = NULL;
|
||||
}
|
||||
}
|
||||
return dirp;
|
||||
}
|
||||
|
||||
void closedir(dirp)
|
||||
DIR *dirp;
|
||||
{
|
||||
fclose(dirp->dirhandle);
|
||||
free(dirp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Apparently originally by Rich Salz.
|
||||
* Cleaned up and modified by James W. Birdsall.
|
||||
*/
|
||||
struct dirent *readdir(dirp)
|
||||
DIR *dirp;
|
||||
{
|
||||
|
||||
if (dirp == NULL)
|
||||
return NULL;
|
||||
|
||||
for (;;)
|
||||
if (fread(&(dirp->entry), sizeof (struct dirent), 1,
|
||||
dirp->dirhandle) == 0)
|
||||
return (struct dirent *)NULL;
|
||||
else if ((dirp->entry).d_ino)
|
||||
return &(dirp->entry);
|
||||
|
||||
} /* end function readdir() */
|
||||
|
||||
#endif /* NO_DIR */
|
||||
|
||||
|
||||
/**********************/
|
||||
/* Function do_wild() */ /* for porting: dir separator; match(ignore_case) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue