#ifndef SPL_DIRECTORY_H
#define SPL_DIRECTORY_H
#include "php.h"
#include "php_spl.h"
extern PHPAPI zend_class_entry *spl_ce_SplFileInfo;
extern PHPAPI zend_class_entry *spl_ce_DirectoryIterator;
extern PHPAPI zend_class_entry *spl_ce_RecursiveDirectoryIterator;
extern PHPAPI zend_class_entry *spl_ce_SplFileObject;
extern PHPAPI zend_class_entry *spl_ce_SplTempFileObject;
PHP_MINIT_FUNCTION(spl_directory);
typedef enum {
SPL_FS_INFO,
SPL_FS_DIR,
SPL_FS_FILE
} SPL_FS_OBJ_TYPE;
typedef struct _spl_filesystem_object spl_filesystem_object;
typedef void (*spl_foreign_dtor_t)(spl_filesystem_object *object TSRMLS_DC);
typedef void (*spl_foreign_clone_t)(spl_filesystem_object *src, spl_filesystem_object *dst TSRMLS_DC);
typedef struct _spl_other_handler {
spl_foreign_dtor_t dtor;
spl_foreign_clone_t clone;
} spl_other_handler;
struct _spl_filesystem_object {
zend_object std;
void *oth;
spl_other_handler *oth_handler;
char *path;
int path_len;
char *file_name;
int file_name_len;
SPL_FS_OBJ_TYPE type;
long flags;
zend_class_entry *file_class;
zend_class_entry *info_class;
union {
struct {
php_stream *dirp;
php_stream_dirent entry;
char *sub_path;
int sub_path_len;
int index;
int is_recursive;
} dir;
struct {
php_stream *stream;
php_stream_context *context;
zval *zcontext;
char *open_mode;
int open_mode_len;
zval *current_zval;
char *current_line;
size_t current_line_len;
size_t max_line_len;
long current_line_num;
zval zresource;
zend_function *func_getCurr;
char delimiter;
char enclosure;
} file;
} u;
};
#define SPL_FILE_OBJECT_DROP_NEW_LINE 0x00000001
#define SPL_FILE_OBJECT_READ_AHEAD 0x00000002
#define SPL_FILE_OBJECT_SKIP_EMPTY 0x00000006
#define SPL_FILE_OBJECT_READ_CSV 0x00000008
#define SPL_FILE_DIR_CURRENT_AS_FILEINFO 0x00000000
#define SPL_FILE_DIR_CURRENT_AS_SELF 0x00000010
#define SPL_FILE_DIR_CURRENT_AS_PATHNAME 0x00000020
#define SPL_FILE_DIR_CURRENT_MODE_MASK 0x000000F0
#define SPL_FILE_DIR_CURRENT(intern,mode) ((intern->flags&SPL_FILE_DIR_CURRENT_MODE_MASK)==mode)
#define SPL_FILE_DIR_KEY_AS_PATHNAME 0x00000000
#define SPL_FILE_DIR_KEY_AS_FILENAME 0x00000100
#define SPL_FILE_DIR_KEY_MODE_MASK 0x00000F00
#define SPL_FILE_DIR_KEY(intern,mode) ((intern->flags&SPL_FILE_DIR_KEY_MODE_MASK)==mode)
#endif