Inheritance diagram for SplFileObject:


Public Member Functions | |
| __construct ($file_name, $open_mode= 'r', $use_include_path=false, $context=NULL) | |
| __toString () | |
| current () | |
| eof () | |
| fflush () | |
| fgetc () | |
| fgetcsv ($delimiter=NULL, $enclosure=NULL) | |
| fgets () | |
| fgetss ($allowable_tags=NULL) | |
| flock ($operation, &$wouldblock) | |
| fpassthru () | |
| fscanf ($format) | |
| fseek ($pos, $whence=SEEK_SET) | |
| fstat () | |
| ftell () | |
| ftruncate ($size) | |
| fwrite ($str, $length=NULL) | |
| getATime () | |
| getChildren () | |
| getCsvControl ($delimiter= ',', $enclosure= '"') | |
| getCTime () | |
| getCurrentLine () | |
| getFileInfo (string class_name=NULL) | |
| getFilename () | |
| getFlags () | |
| getGroup () | |
| getInode () | |
| getLinkTarget () | |
| getMaxLineLen () | |
| getMTime () | |
| getOwner () | |
| getPath () | |
| getPathInfo (string class_name=NULL) | |
| getPathname () | |
| getPerms () | |
| getRealPath () | |
| getSize () | |
| getType () | |
| hasChildren () | |
| isDir () | |
| isExecutable () | |
| isFile () | |
| isLink () | |
| isReadable () | |
| isWritable () | |
| key () | |
| next () | |
| openFile ($mode= 'r', $use_include_path=false, $context=NULL) | |
| rewind () | |
| seek ($line_pos) | |
| setCsvControl ($delimiter= ';', $enclosure= '"') | |
| setFileClass (string class_name="SplFileObject") | |
| setFlags ($flags) | |
| setInfoClass (string class_name="SplFileInfo") | |
| setMaxLineLen ($max_len) | |
| valid () | |
Public Attributes | |
| const | DROP_NEW_LINE = 0x00000001 |
Private Member Functions | |
| freeLine () | |
| readLine () | |
Private Attributes | |
| $delimiter = ',' | |
| $enclosure = '"' | |
| $flags = 0 | |
| $fname | |
| $fp | |
| $line = NULL | |
| $lnum = 0 | |
| $max_len = 0 | |
Definition at line 18 of file splfileobject.inc.
| SplFileObject::__construct | ( | $ | file_name, | |
| $ | open_mode = 'r', |
|||
| $ | use_include_path = false, |
|||
| $ | context = NULL | |||
| ) |
Constructs a new file object.
| $file_name | The name of the stream to open | |
| $open_mode | The file open mode | |
| $use_include_path | Whether to search in include paths | |
| $context | A stream context |
| RuntimeException | If file cannot be opened (e.g. insufficient access rights). |
Definition at line 42 of file splfileobject.inc.
00043 { 00044 $this->fp = fopen($file_name, $open_mode, $use_include_path, $context); 00045 if (!$this->fp) 00046 { 00047 throw new RuntimeException("Cannot open file $file_name"); 00048 } 00049 $this->fname = $file_name; 00050 }
| SplFileObject::__toString | ( | ) |
Reimplemented from SplFileInfo.
Definition at line 359 of file splfileobject.inc.
References current().
00360 { 00361 return current(); 00362 }
Here is the call graph for this function:

| SplFileObject::current | ( | ) |
Implements Iterator.
Definition at line 284 of file splfileobject.inc.
References getCurrentLine().
Referenced by __toString().
00285 { 00286 if (is_null($this->line)) 00287 { 00288 $this->line = getCurrentLine(); 00289 } 00290 return $this->line; 00291 }
Here is the call graph for this function:

| SplFileObject::eof | ( | ) |
Definition at line 55 of file splfileobject.inc.
Referenced by getCurrentLine(), readLine(), seek(), and valid().
00056 { 00057 return eof($this->fp); 00058 }
| SplFileObject::fflush | ( | ) |
Flush current data.
Definition at line 127 of file splfileobject.inc.
00128 { 00129 return fflush($this->fp); 00130 }
| SplFileObject::fgetc | ( | ) |
Definition at line 155 of file splfileobject.inc.
References freeLine().
00156 { 00157 $this->freeLine(); 00158 $c = fgetc($this->fp); 00159 if ($c == '\n') { 00160 $this->lnum++; 00161 } 00162 }
Here is the call graph for this function:

| SplFileObject::fgetcsv | ( | $ | delimiter = NULL, |
|
| $ | enclosure = NULL | |||
| ) |
| delimiter | character used as field separator |
| enclosure | end of |
Definition at line 77 of file splfileobject.inc.
References $delimiter, $enclosure, and freeLine().
00078 { 00079 $this->freeLine(); 00080 $this->lnum++; 00081 switch(fun_num_args()) 00082 { 00083 case 0: 00084 $delimiter = $this->delimiter; 00085 case 1: 00086 $enclosure = $this->enclosure; 00087 default: 00088 case 2: 00089 break; 00090 } 00091 return fgetcsv($this->fp, $this->max_len, $delimiter, $enclosure); 00092 }
Here is the call graph for this function:

| SplFileObject::fgets | ( | ) |
increase current line number
Definition at line 63 of file splfileobject.inc.
References freeLine().
Referenced by readLine().
00064 { 00065 $this->freeLine(); 00066 $this->lnum++; 00067 $buf = fgets($this->fp, $this->max_len); 00068 00069 return $buf; 00070 }
Here is the call graph for this function:

| SplFileObject::fgetss | ( | $ | allowable_tags = NULL |
) |
Get a line from the file and strip HTML tags.
| $allowable_tags | tags to keep in the string |
Definition at line 175 of file splfileobject.inc.
00176 { 00177 return fgetss($this->fp, $allowable_tags); 00178 }
| SplFileObject::flock | ( | $ | operation, | |
| &$ | wouldblock | |||
| ) |
| operation | lock operation (LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB) |
| $wouldblock | whether the operation would block |
Definition at line 118 of file splfileobject.inc.
00119 { 00120 return flock($this->fp, $operation, $wouldblock); 00121 }
| SplFileObject::fpassthru | ( | ) |
Read and return remaining part of stream.
Definition at line 167 of file splfileobject.inc.
00168 { 00169 return fpassthru($this->fp); 00170 }
| SplFileObject::freeLine | ( | ) | [private] |
Free the current line buffer and increment the line counter.
Definition at line 334 of file splfileobject.inc.
Referenced by fgetc(), fgetcsv(), fgets(), fscanf(), getCurrentLine(), next(), readLine(), and rewind().
| SplFileObject::fscanf | ( | $ | format | ) |
Scan the next line.
| $format | string specifying format to parse |
Definition at line 183 of file splfileobject.inc.
References freeLine().
00184 { 00185 $this->freeLine(); 00186 $this->lnum++; 00187 return fscanf($this->fp, $format /* , ... */); 00188 }
Here is the call graph for this function:

| SplFileObject::fseek | ( | $ | pos, | |
| $ | whence = SEEK_SET | |||
| ) |
| pos | new file position |
| whence | seek method (SEEK_SET, SEEK_CUR, SEEK_END) |
Definition at line 146 of file splfileobject.inc.
00147 { 00148 return fseek($this->fp, $pos, $whence); 00149 }
| SplFileObject::fstat | ( | ) |
Definition at line 202 of file splfileobject.inc.
00203 { 00204 return fstat($this->fp); 00205 }
| SplFileObject::ftell | ( | ) |
Definition at line 135 of file splfileobject.inc.
00136 { 00137 return ftell($this->fp); 00138 }
| SplFileObject::ftruncate | ( | $ | size | ) |
| $size | new size to truncate file to |
Definition at line 210 of file splfileobject.inc.
00211 { 00212 return ftruncate($this->fp, $size); 00213 }
| SplFileObject::fwrite | ( | $ | str, | |
| $ | length = NULL | |||
| ) |
| $str | to write |
| $length | maximum line length to write |
Definition at line 194 of file splfileobject.inc.
References $length.
| SplFileInfo::getATime | ( | ) | [inherited] |
| SplFileObject::getChildren | ( | ) |
| SplFileObject::getCsvControl | ( | $ | delimiter = ',', |
|
| $ | enclosure = '"' | |||
| ) |
Definition at line 109 of file splfileobject.inc.
| SplFileInfo::getCTime | ( | ) | [inherited] |
| SplFileObject::getCurrentLine | ( | ) |
Definition at line 346 of file splfileobject.inc.
References eof(), freeLine(), and readLine().
Referenced by current(), and seek().
00347 { 00348 $this->freeLine(); 00349 if ($this->eof()) 00350 { 00351 throw new RuntimeException("Cannot read from file " . $this->fname); 00352 } 00353 $this->readLine(); 00354 }
Here is the call graph for this function:

| SplFileInfo::getFileInfo | ( | string | class_name = NULL |
) | [inherited] |
| class_name | name of class to instantiate |
Definition at line 862 of file spl.php.
| SplFileInfo::getFilename | ( | ) | [inherited] |
| SplFileObject::getFlags | ( | ) |
| SplFileInfo::getGroup | ( | ) | [inherited] |
| SplFileInfo::getInode | ( | ) | [inherited] |
| SplFileInfo::getLinkTarget | ( | ) | [inherited] |
| SplFileObject::getMaxLineLen | ( | ) |
| SplFileInfo::getMTime | ( | ) | [inherited] |
| SplFileInfo::getOwner | ( | ) | [inherited] |
| SplFileInfo::getPath | ( | ) | [inherited] |
| SplFileInfo::getPathInfo | ( | string | class_name = NULL |
) | [inherited] |
| class_name | name of class to instantiate |
Definition at line 872 of file spl.php.
| SplFileInfo::getPathname | ( | ) | [inherited] |
| SplFileInfo::getPerms | ( | ) | [inherited] |
| SplFileInfo::getRealPath | ( | ) | [inherited] |
| SplFileInfo::getSize | ( | ) | [inherited] |
| SplFileInfo::getType | ( | ) | [inherited] |
| SplFileObject::hasChildren | ( | ) |
| SplFileInfo::isDir | ( | ) | [inherited] |
| SplFileInfo::isExecutable | ( | ) | [inherited] |
| SplFileInfo::isFile | ( | ) | [inherited] |
| SplFileInfo::isLink | ( | ) | [inherited] |
Reimplemented in DirectoryIterator.
Definition at line 932 of file spl.php.
| SplFileInfo::isReadable | ( | ) | [inherited] |
| SplFileInfo::isWritable | ( | ) | [inherited] |
| SplFileObject::key | ( | ) |
Line counting works as long as you only read the file and do not use fseek().
Implements Iterator.
Definition at line 301 of file splfileobject.inc.
| SplFileObject::next | ( | ) |
Invalidate current line buffer.
Implements Iterator.
Definition at line 308 of file splfileobject.inc.
References freeLine().
00309 { 00310 $this->freeLine(); 00311 }
Here is the call graph for this function:

| SplFileInfo::openFile | ( | $ | mode = 'r', |
|
| $ | use_include_path = false, |
|||
| $ | context = NULL | |||
| ) | [inherited] |
Open the current file as a SplFileObject instance.
| mode | open mode | |
| use_include_path | whether to search include paths (don't use) | |
| context | resource context to pased to open function |
| RuntimeException | if file cannot be opened (e.g. insufficient access rights). |
file()
Definition at line 959 of file spl.php.
| SplFileObject::readLine | ( | ) | [private] |
Definition at line 316 of file splfileobject.inc.
References eof(), fgets(), and freeLine().
Referenced by getCurrentLine().
00317 { 00318 if ($this->eof()) 00319 { 00320 $this->freeLine(); 00321 throw new RuntimeException("Cannot read from file " . $this->fname); 00322 } 00323 if ($this->line) { 00324 $this->lnum++; 00325 } 00326 $this->freeLine(); 00327 $this->line = fgets($this->fp, $this->max_len); 00328 return $this->line; 00329 }
Here is the call graph for this function:

| SplFileObject::rewind | ( | ) |
Invalidate current line buffer and set line number to 0.
Implements Iterator.
Definition at line 266 of file splfileobject.inc.
References freeLine().
Referenced by seek().
00267 { 00268 $this->freeLine(); 00269 $this->lnum = 0; 00270 }
Here is the call graph for this function:

| SplFileObject::seek | ( | $ | line_pos | ) |
| $line_pos | Seek to this line |
Implements SeekableIterator.
Definition at line 367 of file splfileobject.inc.
References eof(), getCurrentLine(), and rewind().
00368 { 00369 $this->rewind(); 00370 while($this->lnum < $line_pos && !$this->eof()) 00371 { 00372 $this->getCurrentLine(); 00373 } 00374 }
Here is the call graph for this function:

| SplFileObject::setCsvControl | ( | $ | delimiter = ';', |
|
| $ | enclosure = '"' | |||
| ) |
Set the delimiter and enclosure character used in fgetcsv.
| delimiter | new delimiter, defaults to ',' | |
| enclosure | new enclosure, defaults to '"' |
Definition at line 100 of file splfileobject.inc.
References $delimiter, and $enclosure.
00101 { 00102 $this->delimiter = $delimiter; 00103 $this->enclosure = $enclosure; 00104 }
| SplFileInfo::setFileClass | ( | string | class_name = "SplFileObject" |
) | [inherited] |
| class_name | name of class used with openFile(). |
Must be derived from SPLFileObject.
Definition at line 964 of file spl.php.
| SplFileObject::setFlags | ( | $ | flags | ) |
| $flags | new flag set |
Definition at line 218 of file splfileobject.inc.
References $flags.
00219 { 00220 $this->flags = $flags; 00221 }
| SplFileInfo::setInfoClass | ( | string | class_name = "SplFileInfo" |
) | [inherited] |
| class_name | name of class used with getFileInfo(), getPathInfo(). |
Must be derived from SplFileInfo.
Definition at line 969 of file spl.php.
| SplFileObject::setMaxLineLen | ( | $ | max_len | ) |
| $max_len | set the maximum line length read |
Definition at line 234 of file splfileobject.inc.
References $max_len.
00235 { 00236 $this->max_len = $max_len; 00237 }
| SplFileObject::valid | ( | ) |
Implements Iterator.
Definition at line 275 of file splfileobject.inc.
References eof().
00276 { 00277 return !$this->eof(); 00278 }
Here is the call graph for this function:

SplFileObject::$delimiter = ',' [private] |
SplFileObject::$enclosure = '"' [private] |
SplFileObject::$flags = 0 [private] |
SplFileObject::$fname [private] |
Definition at line 24 of file splfileobject.inc.
SplFileObject::$fp [private] |
Definition at line 23 of file splfileobject.inc.
SplFileObject::$line = NULL [private] |
Definition at line 25 of file splfileobject.inc.
SplFileObject::$lnum = 0 [private] |
Definition at line 26 of file splfileobject.inc.
SplFileObject::$max_len = 0 [private] |
| const SplFileObject::DROP_NEW_LINE = 0x00000001 |
1.5.2