diff options
author | Raghubansh Kumar <kraghuba@php.net> | 2007-07-21 17:22:32 +0000 |
---|---|---|
committer | Raghubansh Kumar <kraghuba@php.net> | 2007-07-21 17:22:32 +0000 |
commit | e41c15f71e24cf456f6817a897038ce472ea1a84 (patch) | |
tree | 1d2a15f75437eec7cd75023fc05fd3bd692872e9 | |
parent | edad34bd15f0ae9dbc44724edb8f33ff80a582da (diff) | |
download | php-git-e41c15f71e24cf456f6817a897038ce472ea1a84.tar.gz |
New testcases for fseek(), ftell() & rewind() functions
18 files changed, 13438 insertions, 0 deletions
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_basic1.phpt b/ext/standard/tests/file/fseek_ftell_rewind_basic1.phpt new file mode 100644 index 0000000000..4863b2cca3 --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_basic1.phpt @@ -0,0 +1,845 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : Basic functionality - all r and a modes +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions on all read and append modes */ +echo "*** Testing fseek(), ftell(), rewind() : basic operations ***\n"; +$file_modes = array( "r","rb","rt","r+","r+b","r+t", + "a","ab","at","a+","a+b","a+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$whence_set = array(SEEK_SET,SEEK_CUR,SEEK_END); +$whence_string = array("SEEK_SET", "SEEK_CUR", "SEEK_END"); + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_basic1.tmp"; // this is name of the file created by create_files() + /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + + create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 512, "w", "fseek_ftell_rewind_basic" + ,1,"bytes",".tmp"); //create a file with 512 bytes size + $file_handle = fopen($filename, $file_mode); + if (!$file_handle) { + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + // set the file pointer to 0 + var_dump( rewind($file_handle) ); // Confirm file pointer moves correctly + var_dump( ftell($file_handle) ); // confirm the file pointer position + + foreach($whence_set as $whence){ + echo "-- Testing fseek() with whence = $whence_string[$whence] --\n"; + var_dump( fseek($file_handle,10,$whence) ); //expecting int(0) + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of whence loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_modes loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : basic operations *** + +-- File having data of type text_with_new_line -- +-- File opened in mode r -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode rb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode rt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode ab -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode at -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode r -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode rb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode rt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode ab -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode at -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +Done +--UEXPECT-- + +*** Testing fseek(), ftell(), rewind() : basic operations *** + +-- File having data of type text_with_new_line -- +-- File opened in mode r -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode rb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode rt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode ab -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode at -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode r -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode rb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode rt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode r+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode ab -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode at -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode a+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_basic2-win32.phpt b/ext/standard/tests/file/fseek_ftell_rewind_basic2-win32.phpt new file mode 100644 index 0000000000..aac44800b5 --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_basic2-win32.phpt @@ -0,0 +1,855 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : basic functionality - all w and x modes +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != "WIN" ) + die("skip.. only valid for Windows"); +?> + +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions on all write and create with write modes */ + +echo "*** Testing fseek(), ftell(), rewind() : basic operations ***\n"; +$file_modes = array( "w","wb","wt","w+","w+b","w+t", + "x","xb","xt","x+","x+b","x+t"); + +$file_content_types = array("text_with_new_line","alphanumeric"); + +$whence_set = array(SEEK_SET,SEEK_CUR,SEEK_END); +$whence_string = array("SEEK_SET", "SEEK_CUR", "SEEK_END"); + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_basic2.tmp"; // this is name of the file created by create_files() + +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + + /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + + $file_handle = fopen($filename, $file_mode); + if (!$file_handle) { + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + $data_to_be_written=""; + fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512 + $data_to_be_written = $data_to_be_written; + fwrite($file_handle,(binary)$data_to_be_written); + + // set file pointer to 0 + var_dump( rewind($file_handle) ); // set to begining of file + var_dump( ftell($file_handle) ); + + foreach($whence_set as $whence){ + echo "-- Testing fseek() with whence = $whence_string[$whence] --\n"; + var_dump( fseek($file_handle, 10, $whence) ); //expecting int(0) + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of whence loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of File content type loop +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : basic operations *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(579) +bool(false) +int(569) +-- File opened in mode w+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(579) +bool(false) +int(569) +-- File opened in mode x -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(579) +bool(false) +int(569) +-- File opened in mode x+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(579) +bool(false) +int(569) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : basic operations *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(579) +bool(false) +int(569) +-- File opened in mode w+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(579) +bool(false) +int(569) +-- File opened in mode x -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(579) +bool(false) +int(569) +-- File opened in mode x+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(579) +bool(false) +int(569) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +Done diff --git a/ext/standard/tests/file/fseek_ftell_rewind_basic2.phpt b/ext/standard/tests/file/fseek_ftell_rewind_basic2.phpt new file mode 100644 index 0000000000..1984bbcd28 --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_basic2.phpt @@ -0,0 +1,854 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : basic functionality - all w and x modes +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) == "WIN" ) + die("skip.. Not valid for Windows"); +?> +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions on all write and create with write modes */ + +echo "*** Testing fseek(), ftell(), rewind() : basic operations ***\n"; +$file_modes = array( "w","wb","wt","w+","w+b","w+t", + "x","xb","xt","x+","x+b","x+t"); + +$file_content_types = array("text_with_new_line","alphanumeric"); + +$whence_set = array(SEEK_SET,SEEK_CUR,SEEK_END); +$whence_string = array("SEEK_SET", "SEEK_CUR", "SEEK_END"); + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_basic2.tmp"; // this is name of the file created by create_files() + +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + + /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + + $file_handle = fopen($filename, $file_mode); + if (!$file_handle) { + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + $data_to_be_written=""; + fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512 + $data_to_be_written = $data_to_be_written; + fwrite($file_handle,(binary)$data_to_be_written); + + // set file pointer to 0 + var_dump( rewind($file_handle) ); // set to begining of file + var_dump( ftell($file_handle) ); + + foreach($whence_set as $whence){ + echo "-- Testing fseek() with whence = $whence_string[$whence] --\n"; + var_dump( fseek($file_handle, 10, $whence) ); //expecting int(0) + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of whence loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of File content type loop +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : basic operations *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : basic operations *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode wt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode w+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xb -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode xt -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+ -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+b -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +-- File opened in mode x+t -- +bool(true) +int(0) +-- Testing fseek() with whence = SEEK_SET -- +int(0) +int(10) +bool(false) +-- Testing fseek() with whence = SEEK_CUR -- +int(0) +int(20) +bool(false) +-- Testing fseek() with whence = SEEK_END -- +int(0) +int(522) +bool(false) +int(512) +Done diff --git a/ext/standard/tests/file/fseek_ftell_rewind_error1.phpt b/ext/standard/tests/file/fseek_ftell_rewind_error1.phpt new file mode 100644 index 0000000000..1d18d25b4f --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_error1.phpt @@ -0,0 +1,144 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : error conditions - fseek() +--FILE-- +<?php + +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +echo "*** Testing fseek() : error conditions ***\n"; +// zero argument +echo "-- Testing fseek() with zero argument --\n"; +var_dump( fseek() ); + +// unexpected no. of args +echo "-- Testing fseek() with unexpected number of arguments --\n"; +$fp = fopen(__FILE__, "r"); +var_dump( fseek($fp) ); +var_dump( fseek($fp, 10, $fp,10) ); + +// test invalid arguments : non-resources +echo "-- Testing fseek() with invalid arguments --\n"; +$invalid_args = array ( + "string", + 10, + 10.5, + true, + array(1,2,3), + new stdclass +); +/* loop to test fseek() with different invalid type of args */ +for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) { + echo "-- Iteration $loop_counter --\n"; + var_dump( fseek($invalid_args[$loop_counter - 1], 10) ); +} + +// fseek() on a file handle which is already closed +echo "-- Testing fseek() with closed/unset file handle --"; +fclose($fp); +var_dump(fseek($fp,10)); + +// fseek() on a file handle which is unset +$file_handle = fopen(__FILE__, "r"); +unset($file_handle); //unset file handle +var_dump( fseek(@$file_handle,10)); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek() : error conditions *** +-- Testing fseek() with zero argument -- + +Warning: Wrong parameter count for fseek() in %s on line %d +NULL +-- Testing fseek() with unexpected number of arguments -- + +Warning: Wrong parameter count for fseek() in %s on line %d +NULL + +Warning: Wrong parameter count for fseek() in %s on line %d +NULL +-- Testing fseek() with invalid arguments -- +-- Iteration 1 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Testing fseek() with closed/unset file handle -- +Warning: fseek(): 5 is not a valid stream resource in %s on line %d +bool(false) + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +Done +--UEXPECTF-- +*** Testing fseek() : error conditions *** +-- Testing fseek() with zero argument -- + +Warning: Wrong parameter count for fseek() in %s on line %d +NULL +-- Testing fseek() with unexpected number of arguments -- + +Warning: Wrong parameter count for fseek() in %s on line %d +NULL + +Warning: Wrong parameter count for fseek() in %s on line %d +NULL +-- Testing fseek() with invalid arguments -- +-- Iteration 1 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Testing fseek() with closed/unset file handle -- +Warning: fseek(): 5 is not a valid stream resource in %s on line %d +bool(false) + +Warning: fseek(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/file/fseek_ftell_rewind_error2.phpt b/ext/standard/tests/file/fseek_ftell_rewind_error2.phpt new file mode 100644 index 0000000000..ee2b937276 --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_error2.phpt @@ -0,0 +1,137 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : error conditions - ftell() +--FILE-- +<?php + +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +echo "*** Testing ftell() : error conditions ***\n"; +// zero argument +echo "-- Testing ftell() with zero argument --\n"; +var_dump( ftell() ); + +// more than expected no. of args +echo "-- Testing ftell() with more than expected number of arguments --\n"; +$fp = fopen(__FILE__, "r"); +var_dump( ftell($fp, 10) ); + +// test invalid arguments : non-resources +echo "-- Testing ftell() with invalid arguments --\n"; +$invalid_args = array ( + "string", + 10, + 10.5, + true, + array(1,2,3), + new stdclass, +); +/* loop to test ftell with different invalid type of args */ +for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) { + echo "-- Iteration $loop_counter --\n"; + var_dump( ftell($invalid_args[$loop_counter - 1]) ); +} + +// ftell on a file handle which is already closed +echo "-- Testing ftell with closed/unset file handle --"; +fclose($fp); +var_dump(ftell($fp)); + +// ftell on a file handle which is unset +$file_handle = fopen(__FILE__, "r"); +unset($file_handle); //unset file handle +var_dump( ftell(@$file_handle) ); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing ftell() : error conditions *** +-- Testing ftell() with zero argument -- + +Warning: Wrong parameter count for ftell() in %s on line %d +NULL +-- Testing ftell() with more than expected number of arguments -- + +Warning: Wrong parameter count for ftell() in %s on line %d +NULL +-- Testing ftell() with invalid arguments -- +-- Iteration 1 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Testing ftell with closed/unset file handle -- +Warning: ftell(): 5 is not a valid stream resource in %s on line %d +bool(false) + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +Done +--UEXPECTF-- +*** Testing ftell() : error conditions *** +-- Testing ftell() with zero argument -- + +Warning: Wrong parameter count for ftell() in %s on line %d +NULL +-- Testing ftell() with more than expected number of arguments -- + +Warning: Wrong parameter count for ftell() in %s on line %d +NULL +-- Testing ftell() with invalid arguments -- +-- Iteration 1 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Testing ftell with closed/unset file handle -- +Warning: ftell(): 5 is not a valid stream resource in %s on line %d +bool(false) + +Warning: ftell(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/file/fseek_ftell_rewind_error3.phpt b/ext/standard/tests/file/fseek_ftell_rewind_error3.phpt new file mode 100644 index 0000000000..ca9a375f5e --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_error3.phpt @@ -0,0 +1,137 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : error conditions - rewind() +--FILE-- +<?php + +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +echo "*** Testing rewind() : error conditions ***\n"; +// zero argument +echo "-- Testing rewind() with zero argument --\n"; +var_dump( rewind() ); + +// more than expected no. of args +echo "-- Testing rewind() with more than expected number of arguments --\n"; +$fp = fopen(__FILE__, "r"); +var_dump( rewind($fp, 10) ); + +// test invalid arguments : non-resources +echo "-- Testing rewind() with invalid arguments --\n"; +$invalid_args = array ( + "string", + 10, + 10.5, + true, + array(1,2,3), + new stdclass, +); +/* loop to test rewind with different invalid type of args */ +for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) { + echo "-- Iteration $loop_counter --\n"; + var_dump( rewind($invalid_args[$loop_counter - 1]) ); +} + +// rewind on a file handle which is already closed +echo "-- Testing rewind() with closed/unset file handle --"; +fclose($fp); +var_dump(rewind($fp)); + +// rewind on a file handle which is unset +$file_handle = fopen(__FILE__, "r"); +unset($file_handle); //unset file handle +var_dump( rewind(@$file_handle) ); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing rewind() : error conditions *** +-- Testing rewind() with zero argument -- + +Warning: Wrong parameter count for rewind() in %s on line %d +NULL +-- Testing rewind() with more than expected number of arguments -- + +Warning: Wrong parameter count for rewind() in %s on line %d +NULL +-- Testing rewind() with invalid arguments -- +-- Iteration 1 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Testing rewind() with closed/unset file handle -- +Warning: rewind(): 5 is not a valid stream resource in %s on line %d +bool(false) + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +Done +--UEXPECTF-- +*** Testing rewind() : error conditions *** +-- Testing rewind() with zero argument -- + +Warning: Wrong parameter count for rewind() in %s on line %d +NULL +-- Testing rewind() with more than expected number of arguments -- + +Warning: Wrong parameter count for rewind() in %s on line %d +NULL +-- Testing rewind() with invalid arguments -- +-- Iteration 1 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Testing rewind() with closed/unset file handle -- +Warning: rewind(): 5 is not a valid stream resource in %s on line %d +bool(false) + +Warning: rewind(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation1.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation1.phpt new file mode 100644 index 0000000000..c7d96cf71a --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation1.phpt @@ -0,0 +1,795 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all r & a modes, default whence +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All read and append modes + 2. Testing fseek() without using argument whence +*/ +echo "*** Testing fseek(), ftell(), rewind() : default whence & all r and a modes ***\n"; +$file_modes = array( "r","rb","rt","r+","r+b","r+t", + "a","ab","at","a+","a+b","a+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1, 0, 1, 513); // different offsets, including negative and beyond size + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation1.tmp"; // this is name of the file created by create_files() + + /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + + create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 512, "w", "fseek_ftell_rewind_variation" + ,1,"bytes",".tmp"); //create a file with 512 bytes size + $file_handle = fopen($filename, $file_mode); + if (!$file_handle) { + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + echo "-- Testing fseek() without using argument whence --\n"; + foreach($offset as $count){ + var_dump( fseek($file_handle, $count) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : default whence & all r and a modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode r -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode rb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode rt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode ab -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode at -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode r -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode rb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode rt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode ab -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode at -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : default whence & all r and a modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode r -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode rb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode rt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode ab -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode at -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode r -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode rb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode rt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode r+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode ab -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode at -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode a+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation2-win32.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation2-win32.phpt new file mode 100644 index 0000000000..6920f9d2c6 --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation2-win32.phpt @@ -0,0 +1,804 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, default whence +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != "WIN" ) + die("skip.. only valid for Windows"); +?> +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All write and create with write modes + 2. Testing fseek() without using argument whence +*/ + +echo "*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes ***\n"; +$file_modes = array( "w","wb","wt","w+","w+b","w+t", + "x","xb","xt","x+","x+b","x+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1, 0, 1, 513); // different offsets, including negative and beyond size + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation2.tmp"; // this is name of the file created by create_files() + +/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + $file_handle = fopen($filename, $file_mode); + if (!$file_handle){ + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + $data_to_be_written=""; + fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512 + $data_to_be_written = $data_to_be_written; + fwrite($file_handle,(binary)$data_to_be_written); + rewind($file_handle); + + echo "-- Testing fseek() without using argument whence --\n"; + foreach($offset as $count){ + var_dump( fseek($file_handle,$count) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(569) +-- File opened in mode w+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(569) +-- File opened in mode x -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(569) +-- File opened in mode x+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(569) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(569) +-- File opened in mode w+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(569) +-- File opened in mode x -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(569) +-- File opened in mode x+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(569) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation2.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation2.phpt new file mode 100644 index 0000000000..675c3a0d51 --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation2.phpt @@ -0,0 +1,804 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, default whence +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) == "WIN" ) + die("skip.. Not valid for Windows"); +?> +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All write and create with write modes + 2. Testing fseek() without using argument whence +*/ + +echo "*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes ***\n"; +$file_modes = array( "w","wb","wt","w+","w+b","w+t", + "x","xb","xt","x+","x+b","x+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1, 0, 1, 513); // different offsets, including negative and beyond size + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation2.tmp"; // this is name of the file created by create_files() + +/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + $file_handle = fopen($filename, $file_mode); + if (!$file_handle){ + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + $data_to_be_written=""; + fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512 + $data_to_be_written = $data_to_be_written; + fwrite($file_handle,(binary)$data_to_be_written); + rewind($file_handle); + + echo "-- Testing fseek() without using argument whence --\n"; + foreach($offset as $count){ + var_dump( fseek($file_handle,$count) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode wt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode w+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xb -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode xt -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+ -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+b -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +-- File opened in mode x+t -- +-- Testing fseek() without using argument whence -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation3.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation3.phpt new file mode 100644 index 0000000000..59b92d276a --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation3.phpt @@ -0,0 +1,894 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all r and a modes, SEEK_SET +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All read and append modes + 2. Testing fseek() with whence = SEEK_SET +*/ + +echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all r and a modes ***\n"; + +$file_modes = array( "r","rb","rt","r+","r+b","r+t", + "a","ab","at","a+","a+b","a+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1, 0, 1, 512, 600); // different offsets + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation3.tmp"; // this is name of the file created by create_files() + + /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +echo "*** Testing fseek() with whence = SEEK_SET ***\n"; +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 512, "w", "fseek_ftell_rewind_variation", + 3, "bytes", ".tmp"); //create a file with 512 bytes size + $file_handle = fopen($filename, $file_mode); + if (!$file_handle) { + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + foreach($offset as $count){ + var_dump( fseek($file_handle,$count,SEEK_SET) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all r and a modes *** +*** Testing fseek() with whence = SEEK_SET *** + +-- File having data of type text_with_new_line -- +-- File opened in mode r -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode rb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode rt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode ab -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode at -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode r -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode rb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode rt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode ab -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode at -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all r and a modes *** +*** Testing fseek() with whence = SEEK_SET *** + +-- File having data of type text_with_new_line -- +-- File opened in mode r -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode rb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode rt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode ab -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode at -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode r -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode rb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode rt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode r+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode ab -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode at -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode a+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation4-win32.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation4-win32.phpt new file mode 100644 index 0000000000..5122e4f22b --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation4-win32.phpt @@ -0,0 +1,898 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, SEEK_SET +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != "WIN" ) + die("skip.. only valid for Windows"); +?> +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All write and create with write modes + 2. Testing fseek() with whence = SEEK_SET +*/ +echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all w and x modes ***\n"; +$file_modes = array( "w","wb","wt","w+","w+b","w+t", + "x","xb","xt","x+","x+b","x+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1, 0, 1, 512, 600); // different offsets + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation4.tmp"; // this is name of the file created by create_files() + + /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + $file_handle = fopen($filename, $file_mode); + if (!$file_handle){ + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + $data_to_be_written=""; + fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512 + $data_to_be_written = $data_to_be_written; + fwrite($file_handle,(binary)$data_to_be_written); + rewind($file_handle); + + foreach($offset as $count){ + var_dump( fseek($file_handle,$count,SEEK_SET) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(569) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(569) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(569) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(569) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(569) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(569) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(569) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(569) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation4.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation4.phpt new file mode 100644 index 0000000000..7e922e250e --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation4.phpt @@ -0,0 +1,898 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, SEEK_SET +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) == "WIN" ) + die("skip.. Not valid for Windows"); +?> +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All write and create with write modes + 2. Testing fseek() with whence = SEEK_SET +*/ +echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all w and x modes ***\n"; +$file_modes = array( "w","wb","wt","w+","w+b","w+t", + "x","xb","xt","x+","x+b","x+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1, 0, 1, 512, 600); // different offsets + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation4.tmp"; // this is name of the file created by create_files() + + /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + $file_handle = fopen($filename, $file_mode); + if (!$file_handle){ + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + $data_to_be_written=""; + fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512 + $data_to_be_written = $data_to_be_written; + fwrite($file_handle,(binary)$data_to_be_written); + rewind($file_handle); + + foreach($offset as $count){ + var_dump( fseek($file_handle,$count,SEEK_SET) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(600) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation5.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation5.phpt new file mode 100644 index 0000000000..f42e8b1f07 --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation5.phpt @@ -0,0 +1,887 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all r & a modes, SEEK_CUR +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All read and append modes + 2. Testing fseek() with whence = SEEK_CUR +*/ +echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all r and a modes ***\n"; + +$file_modes = array( "r","rb","rt","r+","r+b","r+t", + "a","ab","at","a+","a+b","a+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1, 0, 1, 512, 600);// different offsets + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation5.tmp"; // this is name of the file created by create_files() + +/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "-- File having data of type ". $file_content_type ." --\n"; + + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 512, "w", "fseek_ftell_rewind_variation" + ,5,"bytes",".tmp"); //create a file with 512 bytes size + $file_handle = fopen($filename, $file_mode); + if (!$file_handle) { + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + rewind($file_handle); + foreach($offset as $count){ + var_dump( fseek($file_handle,$count,SEEK_CUR) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all r and a modes *** +-- File having data of type text_with_new_line -- +-- File opened in mode r -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode rb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode rt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode ab -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode at -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File having data of type alphanumeric -- +-- File opened in mode r -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode rb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode rt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode ab -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode at -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all r and a modes *** +-- File having data of type text_with_new_line -- +-- File opened in mode r -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode rb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode rt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode ab -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode at -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File having data of type alphanumeric -- +-- File opened in mode r -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode rb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode rt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode r+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode ab -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode at -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode a+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation6-win32.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation6-win32.phpt new file mode 100644 index 0000000000..815acece4e --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation6-win32.phpt @@ -0,0 +1,898 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all w & x modes, SEEK_CUR +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != "WIN" ) + die("skip.. only valid for Windows"); +?> +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All write and create with write modes + 2. Testing fseek() with whence = SEEK_CUR +*/ +echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all w and x modes ***\n"; + +$file_modes = array( "w","wb","wt","w+","w+b","w+t", + "x","xb","xt","x+","x+b","x+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1,0,1,512,600); // different offsets + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation6.tmp"; // this is name of the file created by create_files() + +/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + $file_handle = fopen($filename, $file_mode); + if (!$file_handle){ + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + $data_to_be_written=""; + fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512 + $data_to_be_written = $data_to_be_written; + fwrite($file_handle,(binary)$data_to_be_written); + rewind($file_handle); + + foreach($offset as $count){ + var_dump( fseek($file_handle,$count,SEEK_CUR) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(569) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(569) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(569) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(569) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(569) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(569) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(569) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(569) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation6.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation6.phpt new file mode 100644 index 0000000000..49a4965be1 --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation6.phpt @@ -0,0 +1,898 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all w & x modes, SEEK_CUR +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) == "WIN" ) + die("skip.. Not valid for Windows"); +?> +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All write and create with write modes + 2. Testing fseek() with whence = SEEK_CUR +*/ +echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all w and x modes ***\n"; + +$file_modes = array( "w","wb","wt","w+","w+b","w+t", + "x","xb","xt","x+","x+b","x+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1,0,1,512,600); // different offsets + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation6.tmp"; // this is name of the file created by create_files() + +/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + $file_handle = fopen($filename, $file_mode); + if (!$file_handle){ + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + $data_to_be_written=""; + fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512 + $data_to_be_written = $data_to_be_written; + fwrite($file_handle,(binary)$data_to_be_written); + rewind($file_handle); + + foreach($offset as $count){ + var_dump( fseek($file_handle,$count,SEEK_CUR) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all w and x modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode wt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode w+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xb -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode xt -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+ -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+b -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +-- File opened in mode x+t -- +int(-1) +int(0) +bool(false) +int(0) +int(0) +bool(false) +int(0) +int(1) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1113) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation7.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation7.phpt new file mode 100644 index 0000000000..5493621ecc --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation7.phpt @@ -0,0 +1,892 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all r and a modes, SEEK_END +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All read and append modes + 2. Testing fseek() with whence = SEEK_END +*/ + +echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes ***\n"; + +$file_modes = array( "r","rb","rt","r+","r+b","r+t", + "a","ab","at","a+","a+b","a+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1,0,1,512,600);// different offsets + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation7.tmp"; // this is name of the file created by create_files() + +/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 512, "w", "fseek_ftell_rewind_variation" + ,7,"bytes",".tmp"); //create a file with 512 bytes size + $file_handle = fopen($filename, $file_mode); + if (!$file_handle) { + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + rewind($file_handle); + foreach($offset as $count){ + var_dump( fseek($file_handle,$count,SEEK_END) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size, the size will have increased + // by 10 bytes because of holes + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode r -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode rb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode rt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode ab -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode at -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode r -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode rb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode rt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode ab -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode at -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode r -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode rb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode rt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode ab -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode at -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode r -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode rb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode rt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode r+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode ab -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode at -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode a+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation8-win32.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation8-win32.phpt new file mode 100644 index 0000000000..2c08c4c22f --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation8-win32.phpt @@ -0,0 +1,899 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, SEEK_END +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != "WIN" ) + die("skip.. only valid for Windows"); +?> +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All write and create with write modes + 2. Testing fseek() with whence = SEEK_END +*/ +echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes ***\n"; + +$file_modes = array( "w","wb","wt","w+","w+b","w+t", + "x","xb","xt","x+","x+b","x+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1,0,1,512,600); // different offsets + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation8.tmp"; // this is name of the file created by create_files() + +/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + $file_handle = fopen($filename, $file_mode); + if (!$file_handle){ + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + $data_to_be_written=""; + fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512 + $data_to_be_written = $data_to_be_written; + fwrite($file_handle,(binary)$data_to_be_written); + rewind($file_handle); + + foreach($offset as $count){ + var_dump( fseek($file_handle,$count,SEEK_END) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wt -- +int(0) +int(568) +bool(false) +int(0) +int(569) +bool(false) +int(0) +int(570) +bool(false) +int(0) +int(1081) +bool(false) +int(0) +int(1169) +bool(false) +int(569) +-- File opened in mode w+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+t -- +int(0) +int(568) +bool(false) +int(0) +int(569) +bool(false) +int(0) +int(570) +bool(false) +int(0) +int(1081) +bool(false) +int(0) +int(1169) +bool(false) +int(569) +-- File opened in mode x -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xt -- +int(0) +int(568) +bool(false) +int(0) +int(569) +bool(false) +int(0) +int(570) +bool(false) +int(0) +int(1081) +bool(false) +int(0) +int(1169) +bool(false) +int(569) +-- File opened in mode x+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+t -- +int(0) +int(568) +bool(false) +int(0) +int(569) +bool(false) +int(0) +int(570) +bool(false) +int(0) +int(1081) +bool(false) +int(0) +int(1169) +bool(false) +int(569) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wt -- +int(0) +int(568) +bool(false) +int(0) +int(569) +bool(false) +int(0) +int(570) +bool(false) +int(0) +int(1081) +bool(false) +int(0) +int(1169) +bool(false) +int(569) +-- File opened in mode w+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+t -- +int(0) +int(568) +bool(false) +int(0) +int(569) +bool(false) +int(0) +int(570) +bool(false) +int(0) +int(1081) +bool(false) +int(0) +int(1169) +bool(false) +int(569) +-- File opened in mode x -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xt -- +int(0) +int(568) +bool(false) +int(0) +int(569) +bool(false) +int(0) +int(570) +bool(false) +int(0) +int(1081) +bool(false) +int(0) +int(1169) +bool(false) +int(569) +-- File opened in mode x+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+t -- +int(0) +int(568) +bool(false) +int(0) +int(569) +bool(false) +int(0) +int(570) +bool(false) +int(0) +int(1081) +bool(false) +int(0) +int(1169) +bool(false) +int(569) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +Done
\ No newline at end of file diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation8.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation8.phpt new file mode 100644 index 0000000000..cde86ac643 --- /dev/null +++ b/ext/standard/tests/file/fseek_ftell_rewind_variation8.phpt @@ -0,0 +1,899 @@ +--TEST-- +Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, SEEK_END +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) == "WIN" ) + die("skip.. Not valid for Windows"); +?> +--FILE-- +<?php +/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] ); + Description: Seeks on a file pointer + + Prototype: bool rewind ( resource $handle ); + Description: Rewind the position of a file pointer + + Prototype: int ftell ( resource $handle ); + Description: Tells file pointer read/write position +*/ + +// include the file.inc for common functions for test +include ("file.inc"); + +/* Testing fseek(),ftell(),rewind() functions + 1. All write and create with write modes + 2. Testing fseek() with whence = SEEK_END +*/ +echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes ***\n"; + +$file_modes = array( "w","wb","wt","w+","w+b","w+t", + "x","xb","xt","x+","x+b","x+t"); +$file_content_types = array( "text_with_new_line","alphanumeric"); + +$offset = array(-1,0,1,512,600); // different offsets + +$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation8.tmp"; // this is name of the file created by create_files() + +/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */ +foreach($file_content_types as $file_content_type){ + echo "\n-- File having data of type ". $file_content_type ." --\n"; + + foreach($file_modes as $file_mode) { + echo "-- File opened in mode ".$file_mode." --\n"; + $file_handle = fopen($filename, $file_mode); + if (!$file_handle){ + echo "Error: failed to fopen() file: $filename!"; + exit(); + } + $data_to_be_written=""; + fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512 + $data_to_be_written = $data_to_be_written; + fwrite($file_handle,(binary)$data_to_be_written); + rewind($file_handle); + + foreach($offset as $count){ + var_dump( fseek($file_handle,$count,SEEK_END) ); + var_dump( ftell($file_handle) ); // confirm the file pointer position + var_dump( feof($file_handle) ); //ensure that file pointer is not at end + } //end of offset loop + + //close the file and check the size + fclose($file_handle); + var_dump( filesize($filename) ); + + delete_file($filename); // delete file with name + } //end of file_mode loop +} //end of file_content_types loop + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +Done +--UEXPECTF-- +*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes *** + +-- File having data of type text_with_new_line -- +-- File opened in mode w -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) + +-- File having data of type alphanumeric -- +-- File opened in mode w -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode wt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode w+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xb -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode xt -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+ -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+b -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +-- File opened in mode x+t -- +int(0) +int(511) +bool(false) +int(0) +int(512) +bool(false) +int(0) +int(513) +bool(false) +int(0) +int(1024) +bool(false) +int(0) +int(1112) +bool(false) +int(512) +Done
\ No newline at end of file |