cvs: php-src /ext/spl php_spl.c spl.php spl_directory.c spl_directory.h /ext/spl/internal file.inc fileobject.inc

From: Date: Thu, 14 Apr 2005 21:02:09 +0000
Subject: cvs: php-src /ext/spl php_spl.c spl.php spl_directory.c spl_directory.h /ext/spl/internal file.inc fileobject.inc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-31392@lists.php.net to get a copy of this message
helly Thu Apr 14 17:02:09 2005 EDT Added files: /php-src/ext/spl/internal fileobject.inc Removed files: /php-src/ext/spl/internal file.inc Modified files: /php-src/ext/spl php_spl.c spl.php spl_directory.c spl_directory.h Log: - Rename class File to FileObject # by popular demand

http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.46&r2=1.47&ty=u Index: php-src/ext/spl/php_spl.c diff -u php-src/ext/spl/php_spl.c:1.46 php-src/ext/spl/php_spl.c:1.47 --- php-src/ext/spl/php_spl.c:1.46 Wed Apr 6 11:16:43 2005 +++ php-src/ext/spl/php_spl.c Thu Apr 14 17:02:08 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_spl.c,v 1.46 2005/04/06 15:16:43 helly Exp $ */ +/* $Id: php_spl.c,v 1.47 2005/04/14 21:02:08 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -159,7 +159,7 @@ SPL_ADD_CLASS(DirectoryIterator, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(DomainException, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(EmptyIterator, z_list, sub, allow, ce_flags); \ - SPL_ADD_CLASS(File, z_list, sub, allow, ce_flags); \ + SPL_ADD_CLASS(FileObject, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(FilterIterator, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(InfiniteIterator, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(InvalidArgumentException, z_list, sub, allow, ce_flags); \ http://cvs.php.net/diff.php/php-src/ext/spl/spl.php?r1=1.46&r2=1.47&ty=u Index: php-src/ext/spl/spl.php diff -u php-src/ext/spl/spl.php:1.46 php-src/ext/spl/spl.php:1.47 --- php-src/ext/spl/spl.php:1.46 Sat Mar 12 18:03:31 2005 +++ php-src/ext/spl/spl.php Thu Apr 14 17:02:08 2005 @@ -47,12 +47,13 @@ * - class InfiniteIterator extends IteratorIterator * - class AppendIterator implements OuterIterator * - * 2) Directories + * 2) Directories and Files * - * SPL offers two advanced directory classes: + * SPL offers two advanced directory and file handling classes: * * - class DirectoryIterator implements Iterator * - class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveIterator + * - class FileObject implements RecursiveIterator * * 3) XML * @@ -99,8 +100,14 @@ * - interface Observer * - interface Subject * - * A nice article about SPL can be found - * <a href="http://www.sitepoint.com/article/php5-standard-library/1">here</a>. + * Some articles about SPL: + * - <a href="http://www.sitepoint.com/article/php5-standard-library/1">Introducing PHP 5's Standard Library</a> + * - <a href="http://www.phpriot.com/d/articles/php/oop/oop-with-spl-php-5-1/index.html">Advanced OOP with SPL in PHP 5</a> + * - <a href="http://www.devshed.com/c/a/PHP/The-Standard-PHP-Library-Part-1/">The Standard PHP Library, Part 1</a> + * + * Talks on PL: + * - <a href="http://somabo.de/talks/200504_php_quebec_spl_for_the_masses.pps">SPL for the masses [pps]</a> + * - <a href="http://somabo.de/talks/200504_php_quebec_spl_for_the_masses.pdf">SPL for the masses [pdf]</a> * * You can download this documentation as a chm file * <a href="http://php.net/~helly/php/ext/spl/spl.chm">here</a>. @@ -697,6 +704,20 @@ /** @return getFilename() */ function __toString(); + + /** Open the current file as a FileObject instance + * + * @param mode open mode + * @param use_include_path whether to search include paths (don't use) + * @param context resource context to pased to open function + * @throw RuntimeException if file cannot be opened (e.g. insufficient + * access rights). + * @return The opened file as a FileObject instance + * + * @see FileObject + * @see file() + */ + function DirectoryIterator::openFile($mode = 'r', $use_include_path = false, $context = NULL); } /** @ingroup SPL http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.c?r1=1.41&r2=1.42&ty=u Index: php-src/ext/spl/spl_directory.c diff -u php-src/ext/spl/spl_directory.c:1.41 php-src/ext/spl/spl_directory.c:1.42 --- php-src/ext/spl/spl_directory.c:1.41 Thu Mar 31 18:02:20 2005 +++ php-src/ext/spl/spl_directory.c Thu Apr 14 17:02:08 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_directory.c,v 1.41 2005/03/31 23:02:20 helly Exp $ */ +/* $Id: spl_directory.c,v 1.42 2005/04/14 21:02:08 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -50,7 +50,7 @@ /* decalre the class entry */ PHPAPI zend_class_entry *spl_ce_DirectoryIterator; PHPAPI zend_class_entry *spl_ce_RecursiveDirectoryIterator; -PHPAPI zend_class_entry *spl_ce_File; +PHPAPI zend_class_entry *spl_ce_FileObject; static zend_object_value spl_file_object_new_ex(zend_class_entry *class_type, spl_file_object **obj TSRMLS_DC); static int spl_file_object_open(spl_file_object *intern, int use_include_path, int silent TSRMLS_DC); @@ -428,7 +428,7 @@ DirectoryFunction(isLink, FS_IS_LINK) /* }}} */ -/* {{{ proto File DirectoryIterator::openFile([string mode = 'r' [, bool use_include_path [, resource context]]]) +/* {{{ proto FileObject DirectoryIterator::openFile([string mode = 'r' [, bool use_include_path [, resource context]]]) Open the current file */ SPL_METHOD(DirectoryIterator, openFile) { @@ -445,7 +445,7 @@ return; } - return_value->value.obj = spl_file_object_new_ex(spl_ce_File, &intern TSRMLS_CC); + return_value->value.obj = spl_file_object_new_ex(spl_ce_FileObject, &intern TSRMLS_CC); spl_dir_get_path_name(dir_obj); intern->file_name = dir_obj->path_name; @@ -973,7 +973,7 @@ zval *retval; /* if overloaded call the function, otherwise do it directly */ - if (intern->func_getCurr->common.scope != spl_ce_File) { + if (intern->func_getCurr->common.scope != spl_ce_FileObject) { zend_call_method_with_0_params(&getThis(), Z_OBJCE_P(getThis()), &intern->func_getCurr, "getCurrentLine", &retval); if (retval) { if (Z_TYPE_P(retval) == IS_STRING) { @@ -1019,9 +1019,9 @@ return SUCCESS; } /* }}} */ -/* {{{ proto void __construct::File(string filename [, string mode = 'r' [, bool use_include_path [, resource context]]]]) +/* {{{ proto void FileObject::__construct(string filename [, string mode = 'r' [, bool use_include_path [, resource context]]]]) Construct a new file reader */ -SPL_METHOD(File, __construct) +SPL_METHOD(FileObject, __construct) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); zend_bool use_include_path = 0; @@ -1044,9 +1044,9 @@ php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); } /* }}} */ -/* {{{ proto void rewind() +/* {{{ proto void FileObject::rewind() Rewind the file and read the first line */ -SPL_METHOD(File, rewind) +SPL_METHOD(FileObject, rewind) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); @@ -1058,36 +1058,36 @@ } } /* }}} */ -/* {{{ proto string getFilename() +/* {{{ proto string FileObject::getFilename() Return the filename */ -SPL_METHOD(File, getFilename) +SPL_METHOD(FileObject, getFilename) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); RETURN_STRINGL(intern->file_name, intern->file_name_len, 1); } /* }}} */ -/* {{{ proto void eof() +/* {{{ proto void FileObject::eof() Return whether end of file is reached */ -SPL_METHOD(File, eof) +SPL_METHOD(FileObject, eof) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); RETURN_BOOL(php_stream_eof(intern->stream)); } /* }}} */ -/* {{{ proto void valid() +/* {{{ proto void FileObject::valid() Return !eof() */ -SPL_METHOD(File, valid) +SPL_METHOD(FileObject, valid) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); RETVAL_BOOL(!php_stream_eof(intern->stream)); } /* }}} */ -/* {{{ proto string fgets() +/* {{{ proto string FileObject::fgets() Rturn next line from file */ -SPL_METHOD(File, fgets) +SPL_METHOD(FileObject, fgets) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); @@ -1097,9 +1097,9 @@ RETURN_STRINGL(intern->current_line, intern->current_line_len, 1); } /* }}} */ -/* {{{ proto string current() +/* {{{ proto string FileObject::current() Return current line from file */ -SPL_METHOD(File, current) +SPL_METHOD(FileObject, current) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); @@ -1114,9 +1114,9 @@ RETURN_FALSE; } /* }}} */ -/* {{{ proto int key() +/* {{{ proto int FileObject::key() Return line number */ -SPL_METHOD(File, key) +SPL_METHOD(FileObject, key) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); @@ -1126,36 +1126,36 @@ RETURN_LONG(intern->current_line_num); } /* }}} */ -/* {{{ proto void next() +/* {{{ proto void FileObject::next() Read next line */ -SPL_METHOD(File, next) +SPL_METHOD(FileObject, next) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); spl_file_object_free_line(intern TSRMLS_CC); } /* }}} */ -/* {{{ proto void setFlags(int flags) +/* {{{ proto void FileObject::setFlags(int flags) Set file handling flags */ -SPL_METHOD(File, setFlags) +SPL_METHOD(FileObject, setFlags) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intern->flags); } /* }}} */ -/* {{{ proto int getFlags() +/* {{{ proto int FileObject::getFlags() Get file handling flags */ -SPL_METHOD(File, getFlags) +SPL_METHOD(FileObject, getFlags) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); RETURN_LONG(intern->flags); } /* }}} */ -/* {{{ proto void setMaxLineLen(int max_len) +/* {{{ proto void FileObject::setMaxLineLen(int max_len) Set maximum line length */ -SPL_METHOD(File, setMaxLineLen) +SPL_METHOD(FileObject, setMaxLineLen) { long max_len; @@ -1173,9 +1173,9 @@ intern->max_line_len = max_len; } /* }}} */ -/* {{{ proto int getMaxLineLen() +/* {{{ proto int FileObject::getMaxLineLen() Get maximum line length */ -SPL_METHOD(File, getMaxLineLen) +SPL_METHOD(FileObject, getMaxLineLen) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); @@ -1184,14 +1184,14 @@ /* {{{ proto bool hasChildren() Rturn false */ -SPL_METHOD(File, hasChildren) +SPL_METHOD(FileObject, hasChildren) { RETURN_FALSE; } /* }}} */ -/* {{{ proto bool getChildren() +/* {{{ proto bool FileObject::getChildren() Read NULL */ -SPL_METHOD(File, getChildren) +SPL_METHOD(FileObject, getChildren) { /* return NULL */ } /* }}} */ @@ -1248,16 +1248,16 @@ /* {{{ FileFunction */ #define FileFunction(func_name) \ -SPL_METHOD(File, func_name) \ +SPL_METHOD(FileObject, func_name) \ { \ spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \ FileFunctionCall(func_name, NULL); \ } /* }}} */ -/* {{{ proto array File::fgetcsv([string delimiter [, string enclosure]]) +/* {{{ proto array FileObject::fgetcsv([string delimiter [, string enclosure]]) Return current line as csv */ -SPL_METHOD(File, fgetcsv) +SPL_METHOD(FileObject, fgetcsv) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); zval *arg2 = NULL; @@ -1271,14 +1271,14 @@ } /* }}} */ -/* {{{ proto bool File::flock(int operation [, int &wouldblock]) +/* {{{ proto bool FileObject::flock(int operation [, int &wouldblock]) Portable file locking */ FileFunction(flock) /* }}} */ -/* {{{ proto bool File::fflush() +/* {{{ proto bool FileObject::fflush() Flush the file */ -SPL_METHOD(File, fflush) +SPL_METHOD(FileObject, fflush) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); @@ -1286,9 +1286,9 @@ } /* }}} */ -/* {{{ proto int File::ftell() +/* {{{ proto int FileObject::ftell() Return current file position */ -SPL_METHOD(File, ftell) +SPL_METHOD(FileObject, ftell) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); long ret = php_stream_tell(intern->stream); @@ -1300,9 +1300,9 @@ } } /* }}} */ -/* {{{ proto int File::fseek(int pos [, int whence = SEEK_SET]) +/* {{{ proto int FileObject::fseek(int pos [, int whence = SEEK_SET]) Return current file position */ -SPL_METHOD(File, fseek) +SPL_METHOD(FileObject, fseek) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); long pos, whence = SEEK_SET; @@ -1315,9 +1315,9 @@ RETURN_LONG(php_stream_seek(intern->stream, pos, whence)); } /* }}} */ -/* {{{ proto int File::fgetc() +/* {{{ proto int FileObject::fgetc() Get a character form the file */ -SPL_METHOD(File, fgetc) +SPL_METHOD(FileObject, fgetc) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); char buf[2]; @@ -1335,9 +1335,9 @@ } } /* }}} */ -/* {{{ proto string File::fgetss([string allowable_tags]) +/* {{{ proto string FileObject::fgetss([string allowable_tags]) Get a line from file pointer and strip HTML tags */ -SPL_METHOD(File, fgetss) +SPL_METHOD(FileObject, fgetss) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); zval *arg2 = NULL; @@ -1350,18 +1350,18 @@ intern->current_line_num++; } /* }}} */ -/* {{{ proto int File::fpassthru() +/* {{{ proto int FileObject::fpassthru() Output all remaining data from a file pointer */ -SPL_METHOD(File, fpassthru) +SPL_METHOD(FileObject, fpassthru) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); RETURN_LONG(php_stream_passthru(intern->stream)); } /* }}} */ -/* {{{ proto bool File::fscanf(string format [, string ...]) +/* {{{ proto bool FileObject::fscanf(string format [, string ...]) Implements a mostly ANSI compatible fscanf() */ -SPL_METHOD(File, fscanf) +SPL_METHOD(FileObject, fscanf) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); @@ -1371,9 +1371,9 @@ } /* }}} */ -/* {{{ proto mixed File::fwrite(string str [, int length]) +/* {{{ proto mixed FileObject::fwrite(string str [, int length]) Binary-safe file write */ -SPL_METHOD(File, fwrite) +SPL_METHOD(FileObject, fwrite) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); char *str; @@ -1403,14 +1403,14 @@ RETURN_LONG(php_stream_write(intern->stream, str, str_len)); } /* }}} */ -/* {{{ proto bool File::fstat() +/* {{{ proto bool FileObject::fstat() Stat() on a filehandle */ FileFunction(fstat) /* }}} */ -/* {{{ proto bool File::ftruncate(int size) +/* {{{ proto bool FileObject::ftruncate(int size) Truncate file to 'size' length */ -SPL_METHOD(File, ftruncate) +SPL_METHOD(FileObject, ftruncate) { spl_file_object *intern = (spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); long size; @@ -1485,35 +1485,35 @@ ZEND_END_ARG_INFO(); static zend_function_entry spl_file_object_class_functions[] = { - SPL_ME(File, __construct, arginfo_file_object___construct, ZEND_ACC_PUBLIC) - SPL_ME(File, getFilename, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, rewind, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, eof, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, valid, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, fgets, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, fgetcsv, arginfo_file_object_fgetcsv, ZEND_ACC_PUBLIC) - SPL_ME(File, flock, arginfo_file_object_flock, ZEND_ACC_PUBLIC) - SPL_ME(File, fflush, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, ftell, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, fseek, arginfo_file_object_fseek, ZEND_ACC_PUBLIC) - SPL_ME(File, fgetc, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, fpassthru, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, fgetss, arginfo_file_object_fgetss, ZEND_ACC_PUBLIC) - SPL_ME(File, fscanf, arginfo_file_object_fscanf, ZEND_ACC_PUBLIC) - SPL_ME(File, fwrite, arginfo_file_object_fwrite, ZEND_ACC_PUBLIC) - SPL_ME(File, fstat, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, ftruncate, arginfo_file_object_ftruncate, ZEND_ACC_PUBLIC) - SPL_ME(File, current, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, key, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, next, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, setFlags, arginfo_file_object_setFlags, ZEND_ACC_PUBLIC) - SPL_ME(File, getFlags, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, setMaxLineLen, arginfo_file_object_setMaxLineLen, ZEND_ACC_PUBLIC) - SPL_ME(File, getMaxLineLen, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, hasChildren, NULL, ZEND_ACC_PUBLIC) - SPL_ME(File, getChildren, NULL, ZEND_ACC_PUBLIC) - SPL_MA(File, getCurrentLine, File, fgets, NULL, ZEND_ACC_PUBLIC) - SPL_MA(File, __toString, File, current, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, __construct, arginfo_file_object___construct, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, getFilename, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, rewind, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, eof, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, valid, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, fgets, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, fgetcsv, arginfo_file_object_fgetcsv, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, flock, arginfo_file_object_flock, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, fflush, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, ftell, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, fseek, arginfo_file_object_fseek, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, fgetc, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, fpassthru, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, fgetss, arginfo_file_object_fgetss, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, fscanf, arginfo_file_object_fscanf, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, fwrite, arginfo_file_object_fwrite, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, fstat, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, ftruncate, arginfo_file_object_ftruncate, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, current, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, key, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, next, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, setFlags, arginfo_file_object_setFlags, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, getFlags, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, setMaxLineLen, arginfo_file_object_setMaxLineLen, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, getMaxLineLen, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, hasChildren, NULL, ZEND_ACC_PUBLIC) + SPL_ME(FileObject, getChildren, NULL, ZEND_ACC_PUBLIC) + SPL_MA(FileObject, getCurrentLine, FileObject, fgets, NULL, ZEND_ACC_PUBLIC) + SPL_MA(FileObject, __toString, FileObject, current, NULL, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} }; @@ -1534,8 +1534,8 @@ spl_ce_RecursiveDirectoryIterator->get_iterator = spl_ce_dir_tree_get_iterator; - REGISTER_SPL_STD_CLASS_EX(File, spl_file_object_new, spl_file_object_class_functions); - REGISTER_SPL_IMPLEMENTS(File, RecursiveIterator); + REGISTER_SPL_STD_CLASS_EX(FileObject, spl_file_object_new, spl_file_object_class_functions); + REGISTER_SPL_IMPLEMENTS(FileObject, RecursiveIterator); REGISTER_LONG_CONSTANT("FO_DROP_NEW_LINE", (long)SPL_FILE_OBJECT_DROP_NEW_LINE, CONST_CS | CONST_PERSISTENT); http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.h?r1=1.10&r2=1.11&ty=u Index: php-src/ext/spl/spl_directory.h diff -u php-src/ext/spl/spl_directory.h:1.10 php-src/ext/spl/spl_directory.h:1.11 --- php-src/ext/spl/spl_directory.h:1.10 Tue Apr 5 05:23:50 2005 +++ php-src/ext/spl/spl_directory.h Thu Apr 14 17:02:08 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_directory.h,v 1.10 2005/04/05 09:23:50 helly Exp $ */ +/* $Id: spl_directory.h,v 1.11 2005/04/14 21:02:08 helly Exp $ */ #ifndef SPL_DIRECTORY_H #define SPL_DIRECTORY_H @@ -26,7 +26,7 @@ extern PHPAPI zend_class_entry *spl_ce_DirectoryIterator; extern PHPAPI zend_class_entry *spl_ce_RecursiveDirectoryIterator; -extern PHPAPI zend_class_entry *spl_ce_File; +extern PHPAPI zend_class_entry *spl_ce_FileObject; PHP_MINIT_FUNCTION(spl_directory); http://cvs.php.net/co.php/php-src/ext/spl/internal/fileobject.inc?r=1.1&p=1 Index: php-src/ext/spl/internal/fileobject.inc +++ php-src/ext/spl/internal/fileobject.inc <?php /** @file fileobject.inc * @ingroup SPL * @brief class FileObject * @author Marcus Boerger * @date 2003 - 2005 * * SPL - Standard PHP Library */ /** @ingroup SPL * @brief Object representation for any stream * @author Marcus Boerger * @version 1.0 * @since PHP 5.1 */ class FileObject implements RecursiveIterator { private $fp; private $fname; private $line = NULL; private $lnum = 0; private $max_len = 0; private $flags = 0; /** * Constructs a new file object * * @param $file_name The name of the stream to open * @param $open_mode The file open mode * @param $use_include_path Whether to search in include paths * @param $context A stream context * @throw RuntimeException If file cannot be opened (e.g. insufficient * access rights). */ function __construct($file_name, $open_mode = 'r', $use_include_path = false, $context = NULL) { $this->fp = fopen($file_name, $open_mode, $use_include_path, $context); if (!$this->fp) { throw new RuntimeException("Cannot open file $file_name"); } $this->fname = $file_name; } /** * @return the filename as specified in the constructor */ function getFilename() { return $this->fname; } /** * @return whethe rend of stream is reached */ function eof() { return eof($this->fp); } /** increase current line number * @return next line from stream */ function fgets() { $this->lnum++; $buf = fgets($this->fp, $this->max_len); return $buf; } /** * @$delimiter character used as field separator * @enclosure end of */ function fgetcsv($delimiter = ';', $enclosure = '') { $this->lnum++; return fgetcsv($this->fp, $this->max_len, $delimiter, $enclosure); } /** * @param operation lock opeation (LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB) * @retval $wouldblock whether the operation would block */ function flock($operation, &$wouldblock) { return flock($this->fp, $operation, $wouldblock); } /** * Flush current data * @return success or failure */ function fflush() { return fflush($this->fp); } /** * @return current file position */ function ftell() { return ftell($this->fp); } /** * @pos new file position * @whence seek method (SEEK_SET, SEEK_CUR, SEEK_END) */ function fseek($pos, $whence = SEEK_SET) { return fseek($this->fp, $pos, $whence); } /** * @return next char from file * @note a new line character does not increase $this->lnum */ function fgetc() { return fgetc($this->fp); } /** Read and return remaining part of stream * @return size of remaining part passed through */ function fpassthru() { return fpassthru($this->fp); } /** Get a line from the file and strip HTML tags * @param $allow_tags tags to keep in the string */ function fgetss($allowable_tags = NULL) { return fgetss($this->fp, $allowable_tags); } /** Scan the next line * @param $format string specifying format to parse */ function fscanf($format /* , ... */) { $this->lnum++; return fscanf($this->fp, $format /* , ... */); } /** * @param $str to write * @param $lngth maximum line length to write */ function fwrite($str, $length = NULL) { return fwrite($this->fp, $length); } /** * @return array of file stat information */ function fstat() { return fstat($this->fp); } /** * @param new size to truncate file to */ function ftruncate($size) { return ftruncate($this->fp, $size); } /** * @param $flags new flag set */ function setFlags($flags) { $this->flags = $flags; } /** * @return current set of flags */ function getFlags() { return $this->flags; } /** * @param $max_len set the maximum line length read */ function setMaxLineLen($max_len) { $this->max_len = $max_len; } /** * @return curren tsetting for max line */ function getMaxLineLen() { return $this->max_len; } /** * @return false */ function hasChildren() { return false; } /** * @return false */ function getChildren() { return NULL; } /** * Invalidate current line buffer and set line number to 0. */ function rewind() { $this->line = NULL; $this->lnum = 0; } /** * @return whether more data can be read */ function valid() { return !$this->eof(); } /** * @note Fill current line buffer if not done yet. * @return line buffer */ function current() { if (is_null($this->line)) { $this->line = getCurrentLine(); } return $this->line; } /** * @note Fill current line buffer if not done yet. * @return line number */ function key() { if (is_null($this->line)) { $line = getCurrentLine(); } return $this->lnum; } /** Invalidate current line buffer. */ function next() { $this->line = NULL; } /** * @return next line read from file and increase the line counter */ private function readLine() { $this->lnum++; return fgets($this->fp, $this->max_len); } /* * @note if you overload this function key() and current() will increment * $this->lnum. */ function getCurrentLine() { $this->readLine(); } /** * @return current line */ function __toString() { return current(); } } ?>
« previous php.cvs (#31392) next »