Back to index

php5  5.3.10
Classes | Defines | Typedefs | Enumerations | Functions | Variables
spl_directory.h File Reference
#include "php.h"
#include "php_spl.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _spl_other_handler
struct  spl_filesystem_iterator
struct  _spl_filesystem_object
union  _spl_filesystem_object.u
struct  _spl_filesystem_object.u.dir
struct  _spl_filesystem_object.u.file

Defines

#define SPL_FILE_OBJECT_DROP_NEW_LINE   0x00000001 /* drop new lines */
#define SPL_FILE_OBJECT_READ_AHEAD   0x00000002 /* read on rewind/next */
#define SPL_FILE_OBJECT_SKIP_EMPTY   0x00000004 /* skip empty lines */
#define SPL_FILE_OBJECT_READ_CSV   0x00000008 /* read via fgetcsv */
#define SPL_FILE_OBJECT_MASK   0x0000000F /* read via fgetcsv */
#define SPL_FILE_DIR_CURRENT_AS_FILEINFO   0x00000000 /* make RecursiveDirectoryTree::current() return SplFileInfo */
#define SPL_FILE_DIR_CURRENT_AS_SELF   0x00000010 /* make RecursiveDirectoryTree::current() return getSelf() */
#define SPL_FILE_DIR_CURRENT_AS_PATHNAME   0x00000020 /* make RecursiveDirectoryTree::current() return getPathname() */
#define SPL_FILE_DIR_CURRENT_MODE_MASK   0x000000F0 /* mask RecursiveDirectoryTree::current() */
#define SPL_FILE_DIR_CURRENT(intern, mode)   ((intern->flags&SPL_FILE_DIR_CURRENT_MODE_MASK)==mode)
#define SPL_FILE_DIR_KEY_AS_PATHNAME   0x00000000 /* make RecursiveDirectoryTree::key() return getPathname() */
#define SPL_FILE_DIR_KEY_AS_FILENAME   0x00000100 /* make RecursiveDirectoryTree::key() return getFilename() */
#define SPL_FILE_DIR_FOLLOW_SYMLINKS   0x00000200 /* make RecursiveDirectoryTree::hasChildren() follow symlinks */
#define SPL_FILE_DIR_KEY_MODE_MASK   0x00000F00 /* mask RecursiveDirectoryTree::key() */
#define SPL_FILE_DIR_KEY(intern, mode)   ((intern->flags&SPL_FILE_DIR_KEY_MODE_MASK)==mode)
#define SPL_FILE_DIR_SKIPDOTS   0x00001000 /* Tells whether it should skip dots or not */
#define SPL_FILE_DIR_UNIXPATHS   0x00002000 /* Whether to unixify path separators */
#define SPL_FILE_DIR_OTHERS_MASK   0x00003000 /* mask used for get/setFlags */

Typedefs

typedef struct _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_other_handler

Enumerations

enum  SPL_FS_OBJ_TYPE { SPL_FS_INFO, SPL_FS_DIR, SPL_FS_FILE }

Functions

 PHP_MINIT_FUNCTION (spl_directory)
PHPAPI char * spl_filesystem_object_get_path (spl_filesystem_object *intern, int *len TSRMLS_DC)
static spl_filesystem_iteratorspl_filesystem_object_to_iterator (spl_filesystem_object *obj)
static spl_filesystem_object * spl_filesystem_iterator_to_object (spl_filesystem_iterator *it)

Variables

PHPAPI zend_class_entry * spl_ce_SplFileInfo
PHPAPI zend_class_entry * spl_ce_DirectoryIterator
PHPAPI zend_class_entry * spl_ce_FilesystemIterator
PHPAPI zend_class_entry * spl_ce_RecursiveDirectoryIterator
PHPAPI zend_class_entry * spl_ce_GlobIterator
PHPAPI zend_class_entry * spl_ce_SplFileObject
PHPAPI zend_class_entry * spl_ce_SplTempFileObject

Class Documentation

struct _spl_other_handler

Definition at line 50 of file spl_directory.h.

Class Members
spl_foreign_clone_t clone
spl_foreign_dtor_t dtor
struct spl_filesystem_iterator

Definition at line 56 of file spl_directory.h.

Class Members
zval * current
zend_object_iterator intern
spl_filesystem_object * object
struct _spl_filesystem_object

Definition at line 62 of file spl_directory.h.

Collaboration diagram for _spl_filesystem_object:
Class Members
char * _path
int _path_len
zend_class_entry * file_class
char * file_name
int file_name_len
long flags
zend_class_entry * info_class
spl_filesystem_iterator it
char * orig_path
void * oth
spl_other_handler * oth_handler
zend_object std
SPL_FS_OBJ_TYPE type
union _spl_filesystem_object u
union _spl_filesystem_object.u

Definition at line 75 of file spl_directory.h.

Class Members
u dir
u file
struct _spl_filesystem_object.u.dir

Definition at line 76 of file spl_directory.h.

Class Members
php_stream * dirp
php_stream_dirent entry
zend_function * func_next
zend_function * func_rewind
zend_function * func_valid
int index
int is_recursive
char * sub_path
int sub_path_len
struct _spl_filesystem_object.u.file

Definition at line 87 of file spl_directory.h.

Class Members
php_stream_context * context
char * current_line
size_t current_line_len
long current_line_num
zval * current_zval
char delimiter
char enclosure
char escape
zend_function * func_getCurr
size_t max_line_len
char * open_mode
int open_mode_len
php_stream * stream
zval * zcontext
zval zresource

Define Documentation

#define SPL_FILE_DIR_CURRENT (   intern,
  mode 
)    ((intern->flags&SPL_FILE_DIR_CURRENT_MODE_MASK)==mode)

Definition at line 128 of file spl_directory.h.

#define SPL_FILE_DIR_CURRENT_AS_FILEINFO   0x00000000 /* make RecursiveDirectoryTree::current() return SplFileInfo */

Definition at line 124 of file spl_directory.h.

#define SPL_FILE_DIR_CURRENT_AS_PATHNAME   0x00000020 /* make RecursiveDirectoryTree::current() return getPathname() */

Definition at line 126 of file spl_directory.h.

#define SPL_FILE_DIR_CURRENT_AS_SELF   0x00000010 /* make RecursiveDirectoryTree::current() return getSelf() */

Definition at line 125 of file spl_directory.h.

#define SPL_FILE_DIR_CURRENT_MODE_MASK   0x000000F0 /* mask RecursiveDirectoryTree::current() */

Definition at line 127 of file spl_directory.h.

#define SPL_FILE_DIR_FOLLOW_SYMLINKS   0x00000200 /* make RecursiveDirectoryTree::hasChildren() follow symlinks */

Definition at line 132 of file spl_directory.h.

#define SPL_FILE_DIR_KEY (   intern,
  mode 
)    ((intern->flags&SPL_FILE_DIR_KEY_MODE_MASK)==mode)

Definition at line 134 of file spl_directory.h.

#define SPL_FILE_DIR_KEY_AS_FILENAME   0x00000100 /* make RecursiveDirectoryTree::key() return getFilename() */

Definition at line 131 of file spl_directory.h.

#define SPL_FILE_DIR_KEY_AS_PATHNAME   0x00000000 /* make RecursiveDirectoryTree::key() return getPathname() */

Definition at line 130 of file spl_directory.h.

#define SPL_FILE_DIR_KEY_MODE_MASK   0x00000F00 /* mask RecursiveDirectoryTree::key() */

Definition at line 133 of file spl_directory.h.

#define SPL_FILE_DIR_OTHERS_MASK   0x00003000 /* mask used for get/setFlags */

Definition at line 138 of file spl_directory.h.

#define SPL_FILE_DIR_SKIPDOTS   0x00001000 /* Tells whether it should skip dots or not */

Definition at line 136 of file spl_directory.h.

#define SPL_FILE_DIR_UNIXPATHS   0x00002000 /* Whether to unixify path separators */

Definition at line 137 of file spl_directory.h.

#define SPL_FILE_OBJECT_DROP_NEW_LINE   0x00000001 /* drop new lines */

Definition at line 118 of file spl_directory.h.

#define SPL_FILE_OBJECT_MASK   0x0000000F /* read via fgetcsv */

Definition at line 122 of file spl_directory.h.

#define SPL_FILE_OBJECT_READ_AHEAD   0x00000002 /* read on rewind/next */

Definition at line 119 of file spl_directory.h.

#define SPL_FILE_OBJECT_READ_CSV   0x00000008 /* read via fgetcsv */

Definition at line 121 of file spl_directory.h.

#define SPL_FILE_OBJECT_SKIP_EMPTY   0x00000004 /* skip empty lines */

Definition at line 120 of file spl_directory.h.


Typedef Documentation

typedef struct _spl_filesystem_object

Definition at line 43 of file spl_directory.h.

typedef void(* spl_foreign_clone_t)(spl_filesystem_object *src, spl_filesystem_object *dst TSRMLS_DC)

Definition at line 46 of file spl_directory.h.

typedef void(* spl_foreign_dtor_t)(spl_filesystem_object *object TSRMLS_DC)

Definition at line 45 of file spl_directory.h.


Enumeration Type Documentation

Enumerator:
SPL_FS_INFO 
SPL_FS_DIR 
SPL_FS_FILE 

Definition at line 37 of file spl_directory.h.


Function Documentation

PHP_MINIT_FUNCTION ( spl_directory  )

Definition at line 2929 of file spl_directory.c.

{
       REGISTER_SPL_STD_CLASS_EX(SplFileInfo, spl_filesystem_object_new, spl_SplFileInfo_functions);
       memcpy(&spl_filesystem_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
       spl_filesystem_object_handlers.clone_obj       = spl_filesystem_object_clone;
       spl_filesystem_object_handlers.cast_object     = spl_filesystem_object_cast;
       spl_filesystem_object_handlers.get_debug_info  = spl_filesystem_object_get_debug_info;
       spl_ce_SplFileInfo->serialize = zend_class_serialize_deny;
       spl_ce_SplFileInfo->unserialize = zend_class_unserialize_deny;

       REGISTER_SPL_SUB_CLASS_EX(DirectoryIterator, SplFileInfo, spl_filesystem_object_new, spl_DirectoryIterator_functions);
       zend_class_implements(spl_ce_DirectoryIterator TSRMLS_CC, 1, zend_ce_iterator);
       REGISTER_SPL_IMPLEMENTS(DirectoryIterator, SeekableIterator);

       spl_ce_DirectoryIterator->get_iterator = spl_filesystem_dir_get_iterator;

       REGISTER_SPL_SUB_CLASS_EX(FilesystemIterator, DirectoryIterator, spl_filesystem_object_new, spl_FilesystemIterator_functions);

       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "CURRENT_MODE_MASK",   SPL_FILE_DIR_CURRENT_MODE_MASK);
       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "CURRENT_AS_PATHNAME", SPL_FILE_DIR_CURRENT_AS_PATHNAME);
       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "CURRENT_AS_FILEINFO", SPL_FILE_DIR_CURRENT_AS_FILEINFO);
       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "CURRENT_AS_SELF",     SPL_FILE_DIR_CURRENT_AS_SELF);
       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "KEY_MODE_MASK",       SPL_FILE_DIR_KEY_MODE_MASK);
       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "KEY_AS_PATHNAME",     SPL_FILE_DIR_KEY_AS_PATHNAME);
       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "FOLLOW_SYMLINKS",     SPL_FILE_DIR_FOLLOW_SYMLINKS);
       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "KEY_AS_FILENAME",     SPL_FILE_DIR_KEY_AS_FILENAME);
       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "NEW_CURRENT_AND_KEY", SPL_FILE_DIR_KEY_AS_FILENAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO);
       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "SKIP_DOTS",           SPL_FILE_DIR_SKIPDOTS);
       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "UNIX_PATHS",          SPL_FILE_DIR_UNIXPATHS);

       spl_ce_FilesystemIterator->get_iterator = spl_filesystem_tree_get_iterator;

       REGISTER_SPL_SUB_CLASS_EX(RecursiveDirectoryIterator, FilesystemIterator, spl_filesystem_object_new, spl_RecursiveDirectoryIterator_functions);
       REGISTER_SPL_IMPLEMENTS(RecursiveDirectoryIterator, RecursiveIterator);
       
       memcpy(&spl_filesystem_object_check_handlers, &spl_filesystem_object_handlers, sizeof(zend_object_handlers));
       spl_filesystem_object_check_handlers.get_method = spl_filesystem_object_get_method_check;

#ifdef HAVE_GLOB
       REGISTER_SPL_SUB_CLASS_EX(GlobIterator, FilesystemIterator, spl_filesystem_object_new_check, spl_GlobIterator_functions);
       REGISTER_SPL_IMPLEMENTS(GlobIterator, Countable);
#endif

       REGISTER_SPL_SUB_CLASS_EX(SplFileObject, SplFileInfo, spl_filesystem_object_new_check, spl_SplFileObject_functions);
       REGISTER_SPL_IMPLEMENTS(SplFileObject, RecursiveIterator);
       REGISTER_SPL_IMPLEMENTS(SplFileObject, SeekableIterator);

       REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, "DROP_NEW_LINE", SPL_FILE_OBJECT_DROP_NEW_LINE);
       REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, "READ_AHEAD",    SPL_FILE_OBJECT_READ_AHEAD);
       REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, "SKIP_EMPTY",    SPL_FILE_OBJECT_SKIP_EMPTY);
       REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, "READ_CSV",      SPL_FILE_OBJECT_READ_CSV);
       
       REGISTER_SPL_SUB_CLASS_EX(SplTempFileObject, SplFileObject, spl_filesystem_object_new_check, spl_SplTempFileObject_functions);
       return SUCCESS;
}

Here is the call graph for this function:

static spl_filesystem_object* spl_filesystem_iterator_to_object ( spl_filesystem_iterator it) [inline, static]

Definition at line 113 of file spl_directory.h.

{
       return (spl_filesystem_object*)((char*)it - XtOffsetOf(spl_filesystem_object, it));
}

Here is the caller graph for this function:

PHPAPI char* spl_filesystem_object_get_path ( spl_filesystem_object *  intern,
int *len  TSRMLS_DC 
)

Definition at line 177 of file spl_directory.c.

{
#ifdef HAVE_GLOB
       if (intern->type == SPL_FS_DIR) {
              if (php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops)) {
                     return php_glob_stream_get_path(intern->u.dir.dirp, 0, len);
              }
       }
#endif
       if (len) {
              *len = intern->_path_len;
       }
       return intern->_path;
} /* }}} */

Here is the caller graph for this function:

static spl_filesystem_iterator* spl_filesystem_object_to_iterator ( spl_filesystem_object *  obj) [inline, static]

Definition at line 108 of file spl_directory.h.

{
       return &obj->it;
}

Here is the caller graph for this function:


Variable Documentation

PHPAPI zend_class_entry* spl_ce_DirectoryIterator

Definition at line 56 of file spl_directory.c.

PHPAPI zend_class_entry* spl_ce_FilesystemIterator

Definition at line 57 of file spl_directory.c.

PHPAPI zend_class_entry* spl_ce_GlobIterator

Definition at line 59 of file spl_directory.c.

Definition at line 58 of file spl_directory.c.

PHPAPI zend_class_entry* spl_ce_SplFileInfo

Definition at line 55 of file spl_directory.c.

PHPAPI zend_class_entry* spl_ce_SplFileObject

Definition at line 60 of file spl_directory.c.

PHPAPI zend_class_entry* spl_ce_SplTempFileObject

Definition at line 61 of file spl_directory.c.