helly           Thu Sep 15 10:08:17 2005 EDT

  Added files:                 (Branch: PHP_5_1)
    /php-src/ext/spl/internal   splfileobject.inc 

  Removed files:               
    /php-src/ext/spl/internal   fileobject.inc 

  Modified files:              
    /php-src/ext/spl    php_spl.c spl.php spl_directory.c spl_directory.h 
    /php-src/ext/spl/tests      fileobject_001.phpt fileobject_002.phpt 
  Log:
  - Rename file class again by popular demmand: calling it SplFileObject now
  
  
http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.52.2.4&r2=1.52.2.5&ty=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.52.2.4 php-src/ext/spl/php_spl.c:1.52.2.5
--- php-src/ext/spl/php_spl.c:1.52.2.4  Wed Sep 14 23:33:04 2005
+++ php-src/ext/spl/php_spl.c   Thu Sep 15 10:08:14 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_spl.c,v 1.52.2.4 2005/09/15 03:33:04 helly Exp $ */
+/* $Id: php_spl.c,v 1.52.2.5 2005/09/15 14:08:14 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
        #include "config.h"
@@ -161,7 +161,6 @@
        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(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); \
@@ -183,6 +182,7 @@
        SPL_ADD_CLASS(RuntimeException, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(SeekableIterator, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(SimpleXMLIterator, z_list, sub, allow, ce_flags); \
+       SPL_ADD_CLASS(SplFileObject, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(SplObjectStorage, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(SplObserver, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(SplSubject, z_list, sub, allow, ce_flags); \
http://cvs.php.net/diff.php/php-src/ext/spl/spl.php?r1=1.49.2.2&r2=1.49.2.3&ty=u
Index: php-src/ext/spl/spl.php
diff -u php-src/ext/spl/spl.php:1.49.2.2 php-src/ext/spl/spl.php:1.49.2.3
--- php-src/ext/spl/spl.php:1.49.2.2    Wed Sep 14 23:33:04 2005
+++ php-src/ext/spl/spl.php     Thu Sep 15 10:08:14 2005
@@ -53,7 +53,7 @@
  * 
  * - class DirectoryIterator implements Iterator
  * - class RecursiveDirectoryIterator extends DirectoryIterator implements 
RecursiveIterator
- * - class FileObject implements RecursiveIterator, SeekableIterator
+ * - class SplFileObject implements RecursiveIterator, SeekableIterator
  * 
  * 3) XML
  * 
@@ -761,16 +761,16 @@
         */
        function __toString();
 
-       /** Open the current file as a FileObject instance
+       /** Open the current file as a SplFileObject 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
+        * @return The opened file as a SplFileObject instance
         *
-        * @see FileObject
+        * @see SplFileObject
         * @see file()
         */
        function DirectoryIterator::openFile($mode = 'r', $use_include_path = 
false, $context = NULL);
http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.c?r1=1.45.2.1&r2=1.45.2.2&ty=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.45.2.1 
php-src/ext/spl/spl_directory.c:1.45.2.2
--- php-src/ext/spl/spl_directory.c:1.45.2.1    Wed Sep 14 23:33:04 2005
+++ php-src/ext/spl/spl_directory.c     Thu Sep 15 10:08:14 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c,v 1.45.2.1 2005/09/15 03:33:04 helly Exp $ */
+/* $Id: spl_directory.c,v 1.45.2.2 2005/09/15 14:08:14 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_FileObject;
+PHPAPI zend_class_entry *spl_ce_SplFileObject;
 
 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 FileObject DirectoryIterator::openFile([string mode = 'r' [, bool 
use_include_path  [, resource context]]])
+/* {{{ proto SplFileObject 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_FileObject, 
&intern TSRMLS_CC);
+       return_value->value.obj = spl_file_object_new_ex(spl_ce_SplFileObject, 
&intern TSRMLS_CC);
 
        spl_dir_get_path_name(dir_obj);
        intern->file_name = dir_obj->path_name;
@@ -979,7 +979,7 @@
        zval *retval;
 
        /* if overloaded call the function, otherwise do it directly */
-       if (intern->func_getCurr->common.scope != spl_ce_FileObject) {
+       if (intern->func_getCurr->common.scope != spl_ce_SplFileObject) {
                if (php_stream_eof(intern->stream)) {
                        if (!silent) {
                                
zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "Cannot read from 
file %s", intern->file_name);
@@ -1047,9 +1047,9 @@
        return SUCCESS;
 } /* }}} */
 
-/* {{{ proto void FileObject::__construct(string filename [, string mode = 'r' 
[, bool use_include_path  [, resource context]]]])
+/* {{{ proto void SplFileObject::__construct(string filename [, string mode = 
'r' [, bool use_include_path  [, resource context]]]])
    Construct a new file reader */
-SPL_METHOD(FileObject, __construct)
+SPL_METHOD(SplFileObject, __construct)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        zend_bool use_include_path = 0;
@@ -1072,45 +1072,45 @@
        php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 } /* }}} */
 
-/* {{{ proto void FileObject::rewind()
+/* {{{ proto void SplFileObject::rewind()
    Rewind the file and read the first line */
-SPL_METHOD(FileObject, rewind)
+SPL_METHOD(SplFileObject, rewind)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
        spl_file_object_rewind(intern TSRMLS_CC);
 } /* }}} */
 
-/* {{{ proto string FileObject::getFilename()
+/* {{{ proto string SplFileObject::getFilename()
    Return the filename */
-SPL_METHOD(FileObject, getFilename)
+SPL_METHOD(SplFileObject, 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 FileObject::eof()
+/* {{{ proto void SplFileObject::eof()
    Return whether end of file is reached */
-SPL_METHOD(FileObject, eof)
+SPL_METHOD(SplFileObject, 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 FileObject::valid()
+/* {{{ proto void SplFileObject::valid()
    Return !eof() */
-SPL_METHOD(FileObject, valid)
+SPL_METHOD(SplFileObject, 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 FileObject::fgets()
+/* {{{ proto string SplFileObject::fgets()
    Rturn next line from file */
-SPL_METHOD(FileObject, fgets)
+SPL_METHOD(SplFileObject, fgets)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -1120,9 +1120,9 @@
        RETURN_STRINGL(intern->current_line, intern->current_line_len, 1);
 } /* }}} */
 
-/* {{{ proto string FileObject::current()
+/* {{{ proto string SplFileObject::current()
    Return current line from file */
-SPL_METHOD(FileObject, current)
+SPL_METHOD(SplFileObject, current)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -1137,9 +1137,9 @@
        RETURN_FALSE;
 } /* }}} */
 
-/* {{{ proto int FileObject::key()
+/* {{{ proto int SplFileObject::key()
    Return line number */
-SPL_METHOD(FileObject, key)
+SPL_METHOD(SplFileObject, key)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -1150,9 +1150,9 @@
        RETURN_LONG(intern->current_line_num);
 } /* }}} */
 
-/* {{{ proto void FileObject::next()
+/* {{{ proto void SplFileObject::next()
    Read next line */
-SPL_METHOD(FileObject, next)
+SPL_METHOD(SplFileObject, next)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -1160,27 +1160,27 @@
        intern->current_line_num++;
 } /* }}} */
 
-/* {{{ proto void FileObject::setFlags(int flags)
+/* {{{ proto void SplFileObject::setFlags(int flags)
    Set file handling flags */
-SPL_METHOD(FileObject, setFlags)
+SPL_METHOD(SplFileObject, 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 FileObject::getFlags()
+/* {{{ proto int SplFileObject::getFlags()
    Get file handling flags */
-SPL_METHOD(FileObject, getFlags)
+SPL_METHOD(SplFileObject, getFlags)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
        RETURN_LONG(intern->flags);
 } /* }}} */
 
-/* {{{ proto void FileObject::setMaxLineLen(int max_len)
+/* {{{ proto void SplFileObject::setMaxLineLen(int max_len)
    Set maximum line length */
-SPL_METHOD(FileObject, setMaxLineLen)
+SPL_METHOD(SplFileObject, setMaxLineLen)
 {
        long max_len;
 
@@ -1198,9 +1198,9 @@
        intern->max_line_len = max_len;
 } /* }}} */
 
-/* {{{ proto int FileObject::getMaxLineLen()
+/* {{{ proto int SplFileObject::getMaxLineLen()
    Get maximum line length */
-SPL_METHOD(FileObject, getMaxLineLen)
+SPL_METHOD(SplFileObject, getMaxLineLen)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -1209,14 +1209,14 @@
 
 /* {{{ proto bool hasChildren()
    Rturn false */
-SPL_METHOD(FileObject, hasChildren)
+SPL_METHOD(SplFileObject, hasChildren)
 {
        RETURN_FALSE;
 } /* }}} */
 
-/* {{{ proto bool FileObject::getChildren()
+/* {{{ proto bool SplFileObject::getChildren()
    Read NULL */
-SPL_METHOD(FileObject, getChildren)
+SPL_METHOD(SplFileObject, getChildren)
 {
        /* return NULL */
 } /* }}} */
@@ -1273,16 +1273,16 @@
 
 /* {{{ FileFunction */
 #define FileFunction(func_name) \
-SPL_METHOD(FileObject, func_name) \
+SPL_METHOD(SplFileObject, func_name) \
 { \
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
        FileFunctionCall(func_name, NULL); \
 }
 /* }}} */
 
-/* {{{ proto array FileObject::fgetcsv([string delimiter [, string enclosure]])
+/* {{{ proto array SplFileObject::fgetcsv([string delimiter [, string 
enclosure]])
    Return current line as csv */
-SPL_METHOD(FileObject, fgetcsv)
+SPL_METHOD(SplFileObject, fgetcsv)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        zval *arg2 = NULL;
@@ -1298,14 +1298,14 @@
 }
 /* }}} */
 
-/* {{{ proto bool FileObject::flock(int operation [, int &wouldblock])
+/* {{{ proto bool SplFileObject::flock(int operation [, int &wouldblock])
    Portable file locking */
 FileFunction(flock)
 /* }}} */
 
-/* {{{ proto bool FileObject::fflush()
+/* {{{ proto bool SplFileObject::fflush()
    Flush the file */
-SPL_METHOD(FileObject, fflush)
+SPL_METHOD(SplFileObject, fflush)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -1313,9 +1313,9 @@
 } /* }}} */
 
 
-/* {{{ proto int FileObject::ftell()
+/* {{{ proto int SplFileObject::ftell()
    Return current file position */
-SPL_METHOD(FileObject, ftell)
+SPL_METHOD(SplFileObject, ftell)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);  
        long ret = php_stream_tell(intern->stream);
@@ -1327,9 +1327,9 @@
        }
 } /* }}} */
 
-/* {{{ proto int FileObject::fseek(int pos [, int whence = SEEK_SET])
+/* {{{ proto int SplFileObject::fseek(int pos [, int whence = SEEK_SET])
    Return current file position */
-SPL_METHOD(FileObject, fseek)
+SPL_METHOD(SplFileObject, fseek)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        long pos, whence = SEEK_SET;
@@ -1342,9 +1342,9 @@
        RETURN_LONG(php_stream_seek(intern->stream, pos, whence));
 } /* }}} */
 
-/* {{{ proto int FileObject::fgetc()
+/* {{{ proto int SplFileObject::fgetc()
    Get a character form the file */
-SPL_METHOD(FileObject, fgetc)
+SPL_METHOD(SplFileObject, fgetc)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        char buf[2];
@@ -1367,9 +1367,9 @@
        }
 } /* }}} */
 
-/* {{{ proto string FileObject::fgetss([string allowable_tags])
+/* {{{ proto string SplFileObject::fgetss([string allowable_tags])
    Get a line from file pointer and strip HTML tags */
-SPL_METHOD(FileObject, fgetss)
+SPL_METHOD(SplFileObject, fgetss)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        zval *arg2 = NULL;
@@ -1384,18 +1384,18 @@
        zval_ptr_dtor(&arg2);
 } /* }}} */
 
-/* {{{ proto int FileObject::fpassthru()
+/* {{{ proto int SplFileObject::fpassthru()
    Output all remaining data from a file pointer */
-SPL_METHOD(FileObject, fpassthru)
+SPL_METHOD(SplFileObject, 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 FileObject::fscanf(string format [, string ...])
+/* {{{ proto bool SplFileObject::fscanf(string format [, string ...])
    Implements a mostly ANSI compatible fscanf() */
-SPL_METHOD(FileObject, fscanf)
+SPL_METHOD(SplFileObject, fscanf)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -1406,9 +1406,9 @@
 }
 /* }}} */
 
-/* {{{ proto mixed FileObject::fwrite(string str [, int length])
+/* {{{ proto mixed SplFileObject::fwrite(string str [, int length])
    Binary-safe file write */
-SPL_METHOD(FileObject, fwrite)
+SPL_METHOD(SplFileObject, fwrite)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        char *str;
@@ -1438,14 +1438,14 @@
        RETURN_LONG(php_stream_write(intern->stream, str, str_len));
 } /* }}} */
 
-/* {{{ proto bool FileObject::fstat()
+/* {{{ proto bool SplFileObject::fstat()
    Stat() on a filehandle */
 FileFunction(fstat)
 /* }}} */
 
-/* {{{ proto bool FileObject::ftruncate(int size)
+/* {{{ proto bool SplFileObject::ftruncate(int size)
    Truncate file to 'size' length */
-SPL_METHOD(FileObject, ftruncate)
+SPL_METHOD(SplFileObject, ftruncate)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        long size;
@@ -1462,9 +1462,9 @@
        RETURN_BOOL(0 == php_stream_truncate_set_size(intern->stream, size));
 } /* }}} */
 
-/* {{{ proto void FileObject::seek(int line_pos)
+/* {{{ proto void SplFileObject::seek(int line_pos)
    Seek to specified line */
-SPL_METHOD(FileObject, seek)
+SPL_METHOD(SplFileObject, seek)
 {
        spl_file_object *intern = 
(spl_file_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        long line_pos;
@@ -1547,37 +1547,37 @@
 ZEND_END_ARG_INFO();
 
 static zend_function_entry spl_file_object_class_functions[] = {
-       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_ME(FileObject, seek,           arginfo_file_object_seek,          
ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, __construct,    arginfo_file_object___construct,  
 ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, getFilename,    NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, rewind,         NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, eof,            NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, valid,          NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, fgets,          NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, fgetcsv,        arginfo_file_object_fgetcsv,      
 ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, flock,          arginfo_file_object_flock,        
 ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, fflush,         NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, ftell,          NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, fseek,          arginfo_file_object_fseek,        
 ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, fgetc,          NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, fpassthru,      NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, fgetss,         arginfo_file_object_fgetss,       
 ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, fscanf,         arginfo_file_object_fscanf,       
 ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, fwrite,         arginfo_file_object_fwrite,       
 ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, fstat,          NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, ftruncate,      arginfo_file_object_ftruncate,    
 ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, current,        NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, key,            NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, next,           NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, setFlags,       arginfo_file_object_setFlags,     
 ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, getFlags,       NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, setMaxLineLen,  
arginfo_file_object_setMaxLineLen, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, getMaxLineLen,  NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, hasChildren,    NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, getChildren,    NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(SplFileObject, seek,           arginfo_file_object_seek,         
 ZEND_ACC_PUBLIC)
        // mappings
-       SPL_MA(FileObject, getCurrentLine, FileObject, fgets,      NULL, 
ZEND_ACC_PUBLIC)
-       SPL_MA(FileObject, __toString,     FileObject, current,    NULL, 
ZEND_ACC_PUBLIC)
+       SPL_MA(SplFileObject, getCurrentLine, SplFileObject, fgets,      NULL, 
ZEND_ACC_PUBLIC)
+       SPL_MA(SplFileObject, __toString,     SplFileObject, current,    NULL, 
ZEND_ACC_PUBLIC)
        {NULL, NULL, NULL}
 };
 
@@ -1598,11 +1598,11 @@
 
        spl_ce_RecursiveDirectoryIterator->get_iterator = 
spl_ce_dir_tree_get_iterator;
 
-       REGISTER_SPL_STD_CLASS_EX(FileObject, spl_file_object_new, 
spl_file_object_class_functions);
-       REGISTER_SPL_IMPLEMENTS(FileObject, RecursiveIterator);
-       REGISTER_SPL_IMPLEMENTS(FileObject, SeekableIterator);
+       REGISTER_SPL_STD_CLASS_EX(SplFileObject, spl_file_object_new, 
spl_file_object_class_functions);
+       REGISTER_SPL_IMPLEMENTS(SplFileObject, RecursiveIterator);
+       REGISTER_SPL_IMPLEMENTS(SplFileObject, SeekableIterator);
 
-       REGISTER_SPL_CLASS_CONST_LONG(FileObject, "DROP_NEW_LINE", 
SPL_FILE_OBJECT_DROP_NEW_LINE);
+       REGISTER_SPL_CLASS_CONST_LONG(SplFileObject, "DROP_NEW_LINE", 
SPL_FILE_OBJECT_DROP_NEW_LINE);
 
        return SUCCESS;
 }
http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.h?r1=1.12&r2=1.12.2.1&ty=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.12 
php-src/ext/spl/spl_directory.h:1.12.2.1
--- php-src/ext/spl/spl_directory.h:1.12        Wed Aug  3 10:07:53 2005
+++ php-src/ext/spl/spl_directory.h     Thu Sep 15 10:08:14 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.h,v 1.12 2005/08/03 14:07:53 sniper Exp $ */
+/* $Id: spl_directory.h,v 1.12.2.1 2005/09/15 14:08:14 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_FileObject;
+extern PHPAPI zend_class_entry *spl_ce_SplFileObject;
 
 PHP_MINIT_FUNCTION(spl_directory);
 
http://cvs.php.net/diff.php/php-src/ext/spl/tests/fileobject_001.phpt?r1=1.1.2.1&r2=1.1.2.2&ty=u
Index: php-src/ext/spl/tests/fileobject_001.phpt
diff -u php-src/ext/spl/tests/fileobject_001.phpt:1.1.2.1 
php-src/ext/spl/tests/fileobject_001.phpt:1.1.2.2
--- php-src/ext/spl/tests/fileobject_001.phpt:1.1.2.1   Wed Sep 14 23:33:04 2005
+++ php-src/ext/spl/tests/fileobject_001.phpt   Thu Sep 15 10:08:16 2005
@@ -1,13 +1,13 @@
 --TEST--
-SPL: FileObject::seek'ing
+SPL: SplFileObject::seek'ing
 --FILE--
 <?php
 
-$o = new FileObject(dirname(__FILE__) . '/fileobject_001a.txt');
+$o = new SplFileObject(dirname(__FILE__) . '/fileobject_001a.txt');
 
 var_dump($o->key());
 var_dump($o->current());
-$o->setFlags(FileObject::DROP_NEW_LINE);
+$o->setFlags(SplFileObject::DROP_NEW_LINE);
 var_dump($o->key());
 var_dump($o->current());
 var_dump($o->key());
@@ -31,8 +31,8 @@
 }
 
 echo "===B===\n";
-$o = new FileObject(dirname(__FILE__) . '/fileobject_001b.txt');
-$o->setFlags(FileObject::DROP_NEW_LINE);
+$o = new SplFileObject(dirname(__FILE__) . '/fileobject_001b.txt');
+$o->setFlags(SplFileObject::DROP_NEW_LINE);
 foreach($o as $n => $l)
 {
        var_dump($n, $l);
http://cvs.php.net/diff.php/php-src/ext/spl/tests/fileobject_002.phpt?r1=1.1&r2=1.1.2.1&ty=u
Index: php-src/ext/spl/tests/fileobject_002.phpt
diff -u php-src/ext/spl/tests/fileobject_002.phpt:1.1 
php-src/ext/spl/tests/fileobject_002.phpt:1.1.2.1
--- php-src/ext/spl/tests/fileobject_002.phpt:1.1       Tue May  3 18:18:19 2005
+++ php-src/ext/spl/tests/fileobject_002.phpt   Thu Sep 15 10:08:16 2005
@@ -1,5 +1,5 @@
 --TEST--
-SPL: FileObject::fgetc
+SPL: SplFileObject::fgetc
 --FILE--
 <?php
 
@@ -7,7 +7,7 @@
 {
        echo "===$name===\n";
 
-       $o = new FileObject(dirname(__FILE__) . '/' . $name);
+       $o = new SplFileObject(dirname(__FILE__) . '/' . $name);
 
        var_dump($o->key());
        while(($c = $o->fgetc()) !== false)

http://cvs.php.net/co.php/php-src/ext/spl/internal/splfileobject.inc?r=1.1&p=1
Index: php-src/ext/spl/internal/splfileobject.inc
+++ php-src/ext/spl/internal/splfileobject.inc
<?php

/** @file splfileobject.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 SplFileObject implements RecursiveIterator, SeekableIterator
{
        /** Flag: wheter to suppress new lines */
        const DROP_NEW_LINE   = 0x00000001;

        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 whether the end of the stream is reached
         */
        function eof()
        {
                return eof($this->fp);
        }

        /** increase current line number
         * @return next line from stream
         */
        function fgets()
        {
                $this->freeLine();
                $this->lnum++;
                $buf = fgets($this->fp, $this->max_len);
                
                return $buf;
        }

        /**
         * @param delimiter  character used as field separator
         * @param enclosure  end of 
         * @return array containing read data
         */
        function fgetcsv($delimiter = ';', $enclosure = '')
        {
                $this->freeLine();
                $this->lnum++;
                return fgetcsv($this->fp, $this->max_len, $delimiter, 
$enclosure); 
        }

        /**
         * @param operation lock operation (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);
        }

        /**
         * @param pos new file position
         * @param whence seek method (SEEK_SET, SEEK_CUR, SEEK_END)
         * @return Upon success, returns 0; otherwise, returns -1. Note that 
         *         seeking past EOF is not considered an error.
         */
        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()
        {
                $this->freeLine();
                $c = fgetc($this->fp);
                if ($c == '\n') {
                        $this->lnum++;
                }
        }

        /** 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 $allowable_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->freeLine();
                $this->lnum++;
                return fscanf($this->fp, $format /* , ... */);
        }

        /**
         * @param $str to write
         * @param $length 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 $size 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 current setting 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->freeLine();
                $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;
        }

        /**
         * @return line number 
         * @note fgetc() will increase the line number when reaing a new line 
char.
         *       This has the effect key() called on a read a new line will 
already
         *       return the increased line number.
         * @note Line counting works as long as you only read the file and do 
not
         *       use fseek().
         */     
        function key()
        {
                return $this->lnum;
        }

        /** Invalidate current line buffer.
         */     
        function next()
        {
                $this->freeLine();
        }

        /**
         * @return next line read from file and increase the line counter
         */
        private function readLine()
        {
                if ($this->eof())
                {
                        $this->freeLine();
                        throw new RuntimeException("Cannot read from file " . 
$this->fname);
                }
                if ($this->line) {
                        $this->lnum++;
                }
                $this->freeLine();
                $this->line = fgets($this->fp, $this->max_len);
                return $this->line;
        }

        /**
         * Free the current line buffer and increment the line counter
         */
        private function freeLine()
        {
                if ($this->line) {
                        $this->line = NULL;
                }
        }

        /*
         * @note If you DO overload this function key() and current() will 
increment
         *       $this->lnum automatically. If not then function reaLine() will 
do
         *       that for you.
         */ 
        function getCurrentLine()
        {
                $this->freeLine();
                if ($this->eof())
                {
                        throw new RuntimeException("Cannot read from file " . 
$this->fname);
                }
                $this->readLine();
        }

        /**
         * @return current line
         */
        function __toString()
        {
                return current();
        }

        /**
         * @param $line_pos Seek to this line
         */     
        function seek($line_pos)
        {
                $this->rewind();
                while($this->lnum < $line_pos && !$this->eof())
                {
                        $this->getCurrentLine();
                }
        }
}

?>

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to