unixdir.c (mtools-4.0.35.tar.bz2) | : | unixdir.c (mtools-4.0.36.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 28 | skipping to change at line 28 | |||
#include "sysincludes.h" | #include "sysincludes.h" | |||
#include "msdos.h" | #include "msdos.h" | |||
#include "stream.h" | #include "stream.h" | |||
#include "mtools.h" | #include "mtools.h" | |||
#include "file.h" | #include "file.h" | |||
#include "htable.h" | #include "htable.h" | |||
#include "mainloop.h" | #include "mainloop.h" | |||
#include <dirent.h> | #include <dirent.h> | |||
typedef struct Dir_t { | typedef struct Dir_t { | |||
Class_t *Class; | struct Stream_t head; | |||
int refs; | ||||
Stream_t *Next; | ||||
Stream_t *Buffer; | ||||
struct MT_STAT statbuf; | struct MT_STAT statbuf; | |||
char *pathname; | char *pathname; | |||
DIR *dir; | DIR *dir; | |||
#ifdef HAVE_FCHDIR | #ifdef HAVE_FCHDIR | |||
int fd; | int fd; | |||
#endif | #endif | |||
} Dir_t; | } Dir_t; | |||
/*#define FCHDIR_MODE*/ | /*#define FCHDIR_MODE*/ | |||
skipping to change at line 71 | skipping to change at line 68 | |||
DeclareThis(Dir_t); | DeclareThis(Dir_t); | |||
Free(This->pathname); | Free(This->pathname); | |||
closedir(This->dir); | closedir(This->dir); | |||
return 0; | return 0; | |||
} | } | |||
static Class_t DirClass = { | static Class_t DirClass = { | |||
0, /* read */ | 0, /* read */ | |||
0, /* write */ | 0, /* write */ | |||
0, /* pread */ | ||||
0, /* pwrite */ | ||||
0, /* flush */ | 0, /* flush */ | |||
dir_free, /* free */ | dir_free, /* free */ | |||
0, /* get_geom */ | 0, /* get_geom */ | |||
get_dir_data , | get_dir_data , | |||
0, /* pre-allocate */ | 0, /* pre-allocate */ | |||
0, /* get_dosConvert */ | 0, /* get_dosConvert */ | |||
0 /* discard */ | 0 /* discard */ | |||
}; | }; | |||
#ifdef HAVE_FCHDIR | #ifdef HAVE_FCHDIR | |||
skipping to change at line 141 | skipping to change at line 140 | |||
close(fd); | close(fd); | |||
#endif | #endif | |||
return ret; | return ret; | |||
} | } | |||
Stream_t *OpenDir(const char *filename) | Stream_t *OpenDir(const char *filename) | |||
{ | { | |||
Dir_t *This; | Dir_t *This; | |||
This = New(Dir_t); | This = New(Dir_t); | |||
init_head(&This->head, &DirClass, NULL); | ||||
This->Class = &DirClass; | ||||
This->Next = 0; | ||||
This->refs = 1; | ||||
This->Buffer = 0; | ||||
This->pathname = malloc(strlen(filename)+1); | This->pathname = malloc(strlen(filename)+1); | |||
if(This->pathname == NULL) { | if(This->pathname == NULL) { | |||
Free(This); | Free(This); | |||
return NULL; | return NULL; | |||
} | } | |||
strcpy(This->pathname, filename); | strcpy(This->pathname, filename); | |||
if(MT_STAT(filename, &This->statbuf) < 0) { | if(MT_STAT(filename, &This->statbuf) < 0) { | |||
Free(This->pathname); | Free(This->pathname); | |||
Free(This); | Free(This); | |||
return NULL; | return NULL; | |||
} | } | |||
This->dir = opendir(filename); | This->dir = opendir(filename); | |||
if(!This->dir) { | if(!This->dir) { | |||
Free(This->pathname); | Free(This->pathname); | |||
Free(This); | Free(This); | |||
return NULL; | return NULL; | |||
} | } | |||
return (Stream_t *) This; | return &This->head; | |||
} | } | |||
End of changes. 4 change blocks. | ||||
10 lines changed or deleted | 5 lines changed or added |