37#define SPL_HAS_FLAG(flags, test_flag) ((flags & test_flag) ? 1 : 0)
81#define CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(spl_filesystem_object_pointer) \
82 if (!(spl_filesystem_object_pointer)->u.file.stream) { \
83 zend_throw_error(NULL, "Object not initialized"); \
87#define CHECK_DIRECTORY_ITERATOR_IS_INITIALIZED(intern) \
88 if (!(intern)->u.dir.dirp) { \
89 zend_throw_error(NULL, "Object not initialized"); \
105static void spl_filesystem_object_destroy_object(
zend_object *
object)
111 switch(intern->
type) {
139static void spl_filesystem_object_free_storage(
zend_object *
object)
150 zend_string_release(intern->
path);
155 switch(intern->
type) {
170 spl_filesystem_file_free_line(intern);
221 return zend_string_init(tmp,
len,
false);
227 return zend_string_copy(intern->
path);
237 switch (intern->
type) {
282#define IS_SLASH_AT(zs, pos) (IS_SLASH(zs[pos]))
284static inline bool spl_filesystem_is_dot(
const char * d_name)
303 intern->
path = zend_string_copy(path);
312 "Failed to open directory \"%s\"",
ZSTR_VAL(path));
316 spl_filesystem_dir_read(intern);
317 }
while (skip_dots && spl_filesystem_is_dot(intern->
u.
dir.
entry.
d_name));
398 source = spl_filesystem_from_obj(old_object);
399 new_object = spl_filesystem_object_new(old_object->
ce);
400 intern = spl_filesystem_from_obj(new_object);
404 switch (source->
type) {
407 intern->
path = zend_string_copy(source->
path);
414 spl_filesystem_dir_open(intern, source->
path);
418 for (index = 0; index < source->
u.
dir.
index; ++index) {
420 spl_filesystem_dir_read(intern);
421 }
while (skip_dots && spl_filesystem_is_dot(intern->
u.
dir.
entry.
d_name));
432 intern->
oth = source->
oth;
460 intern->
file_name = zend_string_copy(path);
470 zend_string_release(intern->
path);
472 intern->
path = zend_string_init(
ZSTR_VAL(path), path_len, 0);
484 intern = spl_filesystem_from_obj(spl_filesystem_object_new(ce));
492 spl_filesystem_info_set_filename(intern, file_path);
505 switch (source->
type) {
520 intern = spl_filesystem_from_obj(spl_filesystem_object_new(ce));
523 if (spl_filesystem_object_get_file_name(source) ==
FAILURE) {
549 intern = spl_filesystem_from_obj(spl_filesystem_object_new(ce));
552 if (spl_filesystem_object_get_file_name(source) ==
FAILURE) {
587static bool spl_filesystem_is_invalid_or_dot(
const char * d_name)
589 return d_name[0] ==
'\0' || spl_filesystem_is_dot(d_name);
594 switch (intern->
type) {
600 spl_filesystem_object_get_file_name(intern);
618 path_name = spl_filesystem_object_get_pathname(intern);
645 if (spl_intern_is_glob(intern)) {
679 zend_throw_error(
NULL,
"The parent constructor was not called: the object is in an invalid state");
687#define DIT_CTOR_FLAGS 0x00000001
688#define DIT_CTOR_GLOB 0x00000002
727 spl_filesystem_dir_open(intern, path);
728 zend_string_release(path);
732 spl_filesystem_dir_open(intern, path);
758 spl_filesystem_dir_read(intern);
801 spl_filesystem_dir_read(intern);
802 }
while (skip_dots && spl_filesystem_is_dot(intern->
u.
dir.
entry.
d_name));
892 size_t path_len =
ZSTR_LEN(path) + 1;
996 char *fname, *suffix = 0;
1056 path = spl_filesystem_object_get_pathname(intern);
1077 if (spl_filesystem_object_get_file_name(intern) ==
FAILURE) {
1095 if (spl_filesystem_object_get_file_name(intern) ==
FAILURE) {
1100 if (spl_filesystem_object_get_file_name(intern) ==
FAILURE) {
1139 spl_filesystem_info_set_filename(intern, path);
1146#define FileInfoFunction(func_name, func_num) \
1147PHP_METHOD(SplFileInfo, func_name) \
1149 spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); \
1150 zend_error_handling error_handling; \
1151 if (zend_parse_parameters_none() == FAILURE) { \
1154 if (spl_filesystem_object_get_file_name(intern) == FAILURE) { \
1157 zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling);\
1158 php_stat(intern->file_name, func_num, return_value); \
1159 zend_restore_error_handling(&error_handling); \
1235 if (spl_filesystem_object_get_file_name(intern) ==
FAILURE) {
1239#if defined(PHP_WIN32) || defined(HAVE_SYMLINK)
1250 ret = php_sys_readlink(expanded_path, buff,
MAXPATHLEN - 1);
1282 if (spl_filesystem_object_get_file_name(intern) ==
FAILURE) {
1376 path = spl_filesystem_object_get_pathname(intern);
1380 spl_filesystem_object_create_info(dpath, ce,
return_value);
1381 zend_string_release(dpath);
1402 zend_throw_error(
NULL,
"The parent constructor was not called: the object is in an invalid state");
1429 spl_filesystem_dir_read(intern);
1430 }
while (skip_dots && spl_filesystem_is_dot(intern->
u.
dir.
entry.
d_name));
1463 bool allow_links = 0;
1479 if (spl_filesystem_object_get_file_name(intern) ==
FAILURE) {
1509 if (spl_filesystem_object_get_file_name(intern) ==
FAILURE) {
1518 zval_ptr_dtor_str(¶ms[0]);
1519 if (is_initialized ==
FAILURE) {
1538 subdir->
oth = intern->
oth;
1602 if (spl_intern_is_glob(intern)) {
1623 spl_filesystem_dir_it_dtor,
1624 spl_filesystem_dir_it_valid,
1625 spl_filesystem_dir_it_current_data,
1626 spl_filesystem_dir_it_current_key,
1627 spl_filesystem_dir_it_move_forward,
1628 spl_filesystem_dir_it_rewind,
1644 dir_object = spl_filesystem_from_obj(
Z_OBJ_P(
object));
1645 iterator = spl_filesystem_object_to_iterator(dir_object);
1647 iterator->
intern.
funcs = &spl_filesystem_dir_it_funcs;
1652 return &iterator->
intern;
1669 return object->u.dir.entry.d_name[0] !=
'\0' ?
SUCCESS :
FAILURE;
1696 object->u.dir.index++;
1697 spl_filesystem_dir_read(
object);
1699 zend_string_release(
object->file_name);
1700 object->file_name =
NULL;
1710 object->u.dir.index = 0;
1711 if (
object->u.dir.dirp) {
1714 spl_filesystem_dir_read(
object);
1735 if (spl_filesystem_object_get_file_name(
object) ==
FAILURE) {
1743 if (spl_filesystem_object_get_file_name(
object) ==
FAILURE) {
1763 if (spl_filesystem_object_get_file_name(
object) ==
FAILURE) {
1778 object->u.dir.index++;
1780 spl_filesystem_dir_read(
object);
1781 }
while (skip_dots && spl_filesystem_is_dot(
object->u.dir.entry.d_name));
1783 zend_string_release(
object->file_name);
1784 object->file_name =
NULL;
1800 object->u.dir.index = 0;
1801 if (
object->u.dir.dirp) {
1805 spl_filesystem_dir_read(
object);
1806 }
while (skip_dots && spl_filesystem_is_dot(
object->u.dir.entry.d_name));
1816 spl_filesystem_tree_it_dtor,
1817 spl_filesystem_dir_it_valid,
1818 spl_filesystem_tree_it_current_data,
1819 spl_filesystem_tree_it_current_key,
1820 spl_filesystem_tree_it_move_forward,
1821 spl_filesystem_tree_it_rewind,
1837 dir_object = spl_filesystem_from_obj(
Z_OBJ_P(
object));
1838 iterator = spl_filesystem_object_to_iterator(dir_object);
1841 iterator->
intern.
funcs = &spl_filesystem_tree_it_funcs;
1843 return &iterator->
intern;
1855 size_t line_len = 0;
1857 spl_filesystem_file_free_line(intern);
1861 spl_filesystem_file_cannot_read(intern);
1872 buf[line_len] =
'\0';
1882 if (line_len > 0 &&
buf[line_len - 1] ==
'\n') {
1884 if (line_len > 0 &&
buf[line_len - 1] ==
'\r') {
1887 buf[line_len] =
'\0';
1902 return spl_filesystem_file_read_ex(intern, silent, line_add, csv);
1909 return current_line_len == 0 || (
1913 (current_line_len == 1 && current_line[0] ==
'\n')
1914 || (current_line_len == 2 && current_line[0] ==
'\r' && current_line[1] ==
'\n')
1922 zend_result ret = spl_filesystem_file_read(intern, silent,
true);
1940 if (values ==
NULL) {
1960 spl_filesystem_file_free_line(intern);
1964 spl_filesystem_file_cannot_read(intern);
1974 zend_type_error(
"%s::getCurrentLine(): Return value must be of type string, %s returned",
1983 spl_filesystem_file_free_line(intern);
1988 return spl_filesystem_file_read(intern, silent,
false);
1994 zend_result ret = spl_filesystem_file_read_line_ex(this_ptr, intern, silent);
1997 spl_filesystem_file_free_line(intern);
1998 ret = spl_filesystem_file_read_line_ex(this_ptr, intern, silent);
2016 spl_filesystem_file_free_line(intern);
2020 spl_filesystem_file_read_line(this_ptr, intern,
true);
2093 if (max_memory < 0) {
2105 if (spl_filesystem_file_open(intern,
false) ==
SUCCESS) {
2108 zend_string_release(file_name);
2121 spl_filesystem_file_rewind(
ZEND_THIS, intern);
2167 if (spl_filesystem_file_read_ex(intern,
false, 1,
false) ==
FAILURE) {
2185 spl_filesystem_file_read_line(
ZEND_THIS, intern,
true);
2222 spl_filesystem_file_free_line(intern);
2224 spl_filesystem_file_read_line(
ZEND_THIS, intern,
true);
2303 if (escape_str ==
NULL) {
2306 " as its default value will change,"
2307 " either explicitly or via SplFileObject::setCsvControl()");
2324 size_t d_len = 0, e_len = 0;
2338 delimiter = delim[0];
2345 enclosure = enclo[0];
2347 int escape_char = spl_csv_enclosure_param_handling(escape_str, intern, 3);
2352 if (spl_filesystem_file_read_csv(intern, delimiter, enclosure, escape_char,
return_value,
true) ==
FAILURE) {
2364 size_t d_len = 0, e_len = 0;
2379 delimiter = delim[0];
2386 enclosure = enclo[0];
2388 int escape_char = spl_csv_enclosure_param_handling(escape_str, intern, 4);
2405 char delimiter =
',', enclosure =
'"';
2407 size_t d_len = 0, e_len = 0;
2419 delimiter = delim[0];
2426 enclosure = enclo[0];
2432 if (escape_str !=
NULL) {
2446 char delimiter[2], enclosure[2], escape[2];
2455 delimiter[1] =
'\0';
2457 enclosure[1] =
'\0';
2461 escape[0] = (
unsigned char) intern->
u.
file.
escape;
2535 spl_filesystem_file_free_line(intern);
2550 spl_filesystem_file_free_line(intern);
2581 uint32_t num_varargs = 0;
2593 if (spl_filesystem_file_read(intern,
false,
false) ==
FAILURE) {
2622 str_len =
MIN((
size_t)length, str_len);
2721 spl_filesystem_file_rewind(
ZEND_THIS, intern);
2723 for (i = 0; i < line_pos; i++) {
2730 spl_filesystem_file_free_line(intern);
2764 spl_filesystem_object_handlers.clone_obj = spl_filesystem_object_clone;
2765 spl_filesystem_object_handlers.dtor_obj = spl_filesystem_object_destroy_object;
2766 spl_filesystem_object_handlers.free_obj = spl_filesystem_object_free_storage;
2780 spl_filesystem_object_check_handlers.clone_obj =
NULL;
2781 spl_filesystem_object_check_handlers.get_method = spl_filesystem_object_get_method_check;
ftruncate($stream, int $size)
fputcsv($stream, array $fields, string $separator=",", string $enclosure="\"", string $escape="\\", string $eol="\n")
fgetcsv($stream, ?int $length=null, string $separator=",", string $enclosure="\"", string $escape="\\")
fseek($stream, int $offset, int $whence=SEEK_SET)
fwrite($stream, string $data, ?int $length=null)
count(Countable|array $value, int $mode=COUNT_NORMAL)
fscanf($stream, string $format, mixed &... $vars)
fread($stream, int $length)
flock($stream, int $operation, &$would_block=null)
fgets($stream, ?int $length=null)
memset(ptr, 0, type->size)
zend_ffi_ctype_name_buf buf
PHPAPI void php_fstat(php_stream *stream, zval *return_value)
PHPAPI HashTable * php_bc_fgetcsv_empty_line(void)
PHPAPI HashTable * php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int escape_char, size_t buf_len, char *buf)
PHPAPI int php_csv_handle_escape_argument(const zend_string *escape_str, uint32_t arg_num)
PHPAPI ssize_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, int escape_char, zend_string *eol_str)
PHPAPI void php_flock_common(php_stream *stream, zend_long operation, uint32_t operation_arg_num, zval *wouldblock, zval *return_value)
PHPAPI void php_stat(zend_string *filename, int type, zval *return_value)
PHPAPI char * expand_filepath_with_mode(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len, int realpath_mode)
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
#define PHP_MINIT_FUNCTION
unsigned const char * pos
#define PHP_STREAM_MAX_MEM
unsigned char key[REFLECTION_KEY_LEN]
#define php_stream_context_from_zval(zcontext, nocontext)
#define php_glob_stream_get_path(stream, plen)
#define php_glob_stream_get_count(stream, pflags)
PHPAPI const php_stream_ops php_glob_stream_ops
#define php_stream_truncate_supported(stream)
#define php_stream_pclose(stream)
#define php_stream_readdir(dirstream, dirent)
#define php_stream_rewind(stream)
#define php_stream_get_line(stream, buf, maxlen, retlen)
#define php_stream_getc(stream)
#define php_stream_seek(stream, offset, whence)
#define php_stream_flush(stream)
PHPAPI zend_string * php_stream_read_to_str(php_stream *stream, size_t len)
#define php_stream_opendir(path, options, context)
#define php_stream_truncate_set_size(stream, size)
#define php_stream_eof(stream)
#define php_stream_open_wrapper_ex(path, mode, options, opened, context)
#define php_stream_close(stream)
#define php_stream_is(stream, anops)
#define php_stream_tell(stream)
#define php_stream_rewinddir(dirstream)
#define PHP_STREAM_FLAG_NO_FCLOSE
#define php_stream_passthru(stream)
#define php_stream_write(stream, buf, count)
PHPAPI zend_string * php_basename(const char *s, size_t len, const char *suffix, size_t sufflen)
PHPAPI int php_sscanf_internal(char *string, char *format, int argCount, zval *args, int varStart, zval *return_value)
#define SCAN_ERROR_WRONG_PARAM_COUNT
PHPAPI zend_class_entry * spl_ce_FilesystemIterator
PHPAPI zend_string * spl_filesystem_object_get_path(const spl_filesystem_object *intern)
#define IS_SLASH_AT(zs, pos)
PHPAPI zend_class_entry * spl_ce_SplFileObject
#define CHECK_DIRECTORY_ITERATOR_IS_INITIALIZED(intern)
#define CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(spl_filesystem_object_pointer)
PHPAPI zend_class_entry * spl_ce_SplTempFileObject
PHPAPI zend_class_entry * spl_ce_SplFileInfo
PHPAPI zend_class_entry * spl_ce_GlobIterator
PHPAPI zend_class_entry * spl_ce_DirectoryIterator
#define SPL_HAS_FLAG(flags, test_flag)
PHPAPI zend_class_entry * spl_ce_RecursiveDirectoryIterator
#define FileInfoFunction(func_name, func_num)
#define SPL_FILE_DIR_OTHERS_MASK
#define SPL_FILE_DIR_KEY_MODE_MASK
#define SPL_FILE_DIR_FOLLOW_SYMLINKS
struct _spl_filesystem_object spl_filesystem_object
#define SPL_FILE_DIR_KEY(intern, mode)
#define SPL_FILE_DIR_CURRENT_AS_SELF
#define SPL_FILE_DIR_KEY_AS_PATHNAME
#define SPL_FILE_DIR_CURRENT_MODE_MASK
#define SPL_FILE_OBJECT_SKIP_EMPTY
#define SPL_FILE_OBJECT_READ_CSV
#define SPL_FILE_OBJECT_MASK
#define SPL_FILE_OBJECT_DROP_NEW_LINE
#define SPL_FILE_DIR_KEY_AS_FILENAME
#define SPL_FILE_DIR_SKIPDOTS
#define SPL_FILE_DIR_UNIXPATHS
#define SPL_FILE_DIR_CURRENT_AS_PATHNAME
#define SPL_FILE_DIR_CURRENT_AS_FILEINFO
#define SPL_FILE_DIR_CURRENT(intern, mode)
#define SPL_FILE_OBJECT_READ_AHEAD
PHPAPI zend_class_entry * spl_ce_LogicException
PHPAPI zend_class_entry * spl_ce_RuntimeException
PHPAPI zend_class_entry * spl_ce_UnexpectedValueException
PHPAPI zend_class_entry * spl_ce_OutOfBoundsException
void spl_set_private_debug_info_property(const zend_class_entry *ce, const char *property, size_t property_len, HashTable *debug_info, zval *value)
PHPAPI zend_class_entry * spl_ce_RecursiveIterator
PHPAPI zend_class_entry * spl_ce_SeekableIterator
#define PHP_CSV_NO_ESCAPE
#define PHP_CSV_ESCAPE_ERROR
zend_function * func_next
zend_function * func_rewind
zend_function * func_valid
php_stream_context * context
zend_long current_line_num
zend_string * current_line
const spl_other_handler * oth_handler
zend_class_entry * file_class
union _spl_filesystem_object::@054265167067030002056020365222237177377222266163 u
zend_function * func_getCurr
struct _spl_filesystem_object::@054265167067030002056020365222237177377222266163::@257240036270267375207030141122200245165352304006 dir
zend_class_entry * info_class
struct _spl_filesystem_object::@054265167067030002056020365222237177377222266163::@333212215061307125335046006116147322016236071114 file
spl_foreign_clone_t clone
zend_function * constructor
const zend_object_iterator_funcs * funcs
zend_object_iterator intern
struct _zend_function::@236135173067030250234125302313220025134003177336 common
ZEND_API zend_string * zend_strpprintf(size_t max_len, const char *format,...)
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
ZEND_API ZEND_COLD void zend_type_error(const char *format,...)
ZEND_API ZEND_COLD void zend_value_error(const char *format,...)
#define INTERNAL_FUNCTION_PARAMETERS
ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current)
ZEND_API void zend_restore_error_handling(zend_error_handling *saved)
#define INTERNAL_FUNCTION_PARAM_PASSTHRU
ZEND_API const char * zend_zval_value_name(const zval *arg)
ZEND_API zend_result object_init_with_constructor(zval *arg, zend_class_entry *class_type, uint32_t param_count, zval *params, HashTable *named_params)
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type)
ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num)
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format,...)
ZEND_API zend_result add_next_index_string(zval *arg, const char *str)
#define ZEND_PARSE_PARAMETERS_END()
#define ZVAL_STRING(z, s)
#define RETVAL_STR_COPY(s)
#define zend_parse_parameters_none()
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
#define RETURN_NEW_STR(s)
#define RETURN_OBJ_COPY(r)
#define Z_PARAM_BOOL(dest)
#define RETURN_EMPTY_STRING()
#define ZVAL_STRINGL(z, s, l)
#define WRONG_PARAM_COUNT
#define RETVAL_STRINGL(s, l)
#define RETURN_STR_COPY(s)
#define ZVAL_EMPTY_STRING(z)
#define estrndup(s, length)
#define ecalloc(nmemb, size)
#define safe_emalloc(nmemb, size, offset)
strcmp(string $string1, string $string2)
zend_string_release_ex(func->internal_function.function_name, 0)
ZEND_API size_t zend_dirname(char *path, size_t len)
ZEND_API ZEND_COLD zend_object * zend_throw_exception_ex(zend_class_entry *exception_ce, zend_long code, const char *format,...)
union _zend_function zend_function
ZEND_API HashTable *ZEND_FASTCALL zend_array_dup(HashTable *source)
ZEND_API zend_class_entry * zend_ce_countable
ZEND_API zend_class_entry * zend_ce_stringable
ZEND_API void zend_iterator_init(zend_object_iterator *iter)
struct _zend_object_iterator zend_object_iterator
struct _zend_object_iterator_funcs zend_object_iterator_funcs
struct _zend_string zend_string
ZEND_API zend_function * zend_std_get_method(zend_object **obj_ptr, zend_string *method_name, const zval *key)
ZEND_API const zend_object_handlers std_object_handlers
ZEND_API void zend_objects_destroy_object(zend_object *object)
ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object, zend_object *old_object)
ZEND_API void ZEND_FASTCALL zend_object_std_init(zend_object *object, zend_class_entry *ce)
ZEND_API void zend_object_std_dtor(zend_object *object)
ZEND_API bool ZEND_FASTCALL zend_is_true(const zval *op)
#define XtOffsetOf(s_type, field)
#define ZEND_UNREACHABLE()
#define UNEXPECTED(condition)
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
ZEND_API zend_string * zend_string_concat3(const char *str1, size_t str1_len, const char *str2, size_t str2_len, const char *str3, size_t str3_len)
#define ZSTR_INIT_LITERAL(s, persistent)
#define ZSTR_EMPTY_ALLOC()
#define zend_string_starts_with_literal(str, prefix)
#define ZVAL_STR_COPY(z, s)
struct _zend_array HashTable
#define Z_OBJCE_P(zval_p)
#define ZVAL_OBJ_COPY(z, o)
ZEND_RESULT_CODE zend_result
struct _zend_object_handlers zend_object_handlers
ZEND_API void zval_ptr_dtor(zval *zval_ptr)
#define IS_ABSOLUTE_PATH(path, len)
#define VCWD_ACCESS(pathname, mode)
#define VCWD_REALPATH(path, real_path)