Annotation of embedaddon/php/ext/standard/tests/file/fseek_ftell_rewind_variation2-win32.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, default whence
                      3: --SKIPIF--
                      4: <?php
                      5: if( substr(PHP_OS, 0, 3) != "WIN" )
                      6:   die("skip.. only valid for Windows");
                      7: ?>
                      8: --FILE--
                      9: <?php
                     10: /* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
                     11:    Description: Seeks on a file pointer
                     12: 
                     13:    Prototype: bool rewind ( resource $handle );
                     14:    Description: Rewind the position of a file pointer
                     15: 
                     16:    Prototype: int ftell ( resource $handle );
                     17:    Description: Tells file pointer read/write position
                     18: */
                     19: 
                     20: // include the file.inc for common functions for test
                     21: include ("file.inc");
                     22: 
                     23: /* Testing fseek(),ftell(),rewind() functions 
                     24:      1. All  write and create with write modes
                     25:      2. Testing fseek() without using argument whence 
                     26: */
                     27: 
                     28: echo "*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes ***\n";
                     29: $file_modes = array( "w","wb","wt","w+","w+b","w+t", 
                     30:                      "x","xb","xt","x+","x+b","x+t");
                     31: $file_content_types = array( "text_with_new_line","alphanumeric");
                     32: 
                     33: $offset = array(-1, 0, 1, 513); // different offsets, including negative and beyond size
                     34: 
                     35: $filename = dirname(__FILE__)."/fseek_ftell_rewind_variation2.tmp"; // this is name of the file created by create_files()
                     36: 
                     37: /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
                     38: foreach($file_content_types as $file_content_type){
                     39:   echo "\n-- File having data of type ". $file_content_type ." --\n";
                     40: 
                     41:   foreach($file_modes as $file_mode) {
                     42:     echo "-- File opened in mode ".$file_mode." --\n";
                     43:     $file_handle = fopen($filename, $file_mode);
                     44:     if (!$file_handle){
                     45:       echo "Error: failed to fopen() file: $filename!";
                     46:       exit();
                     47:     }
                     48:     $data_to_be_written="";
                     49:     fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
                     50:     $data_to_be_written = $data_to_be_written;
                     51:     fwrite($file_handle,(binary)$data_to_be_written);
                     52:     rewind($file_handle);
                     53: 
                     54:     echo "-- Testing fseek() without using argument whence --\n";
                     55:     foreach($offset as $count){
                     56:       var_dump( fseek($file_handle,$count) ); 
                     57:       var_dump( ftell($file_handle) ); // confirm the file pointer position
                     58:       var_dump( feof($file_handle) ); //ensure that file pointer is not at end
                     59:     } //end of offset loop
                     60: 
                     61:     //close the file and check the size
                     62:     fclose($file_handle);
                     63:     var_dump( filesize($filename) );
                     64: 
                     65:     delete_file($filename); // delete file with name
                     66:   } //end of file_mode loop
                     67: } //end of file_content_types loop
                     68: 
                     69: echo "Done\n";
                     70: ?>
                     71: --EXPECTF--
                     72: *** Testing fseek(), ftell(), rewind() : default whence & all w and x modes ***
                     73: 
                     74: -- File having data of type text_with_new_line --
                     75: -- File opened in mode w --
                     76: -- Testing fseek() without using argument whence --
                     77: int(-1)
                     78: int(0)
                     79: bool(false)
                     80: int(0)
                     81: int(0)
                     82: bool(false)
                     83: int(0)
                     84: int(1)
                     85: bool(false)
                     86: int(0)
                     87: int(513)
                     88: bool(false)
                     89: int(512)
                     90: -- File opened in mode wb --
                     91: -- Testing fseek() without using argument whence --
                     92: int(-1)
                     93: int(0)
                     94: bool(false)
                     95: int(0)
                     96: int(0)
                     97: bool(false)
                     98: int(0)
                     99: int(1)
                    100: bool(false)
                    101: int(0)
                    102: int(513)
                    103: bool(false)
                    104: int(512)
                    105: -- File opened in mode wt --
                    106: -- Testing fseek() without using argument whence --
                    107: int(-1)
                    108: int(0)
                    109: bool(false)
                    110: int(0)
                    111: int(0)
                    112: bool(false)
                    113: int(0)
                    114: int(1)
                    115: bool(false)
                    116: int(0)
                    117: int(513)
                    118: bool(false)
                    119: int(569)
                    120: -- File opened in mode w+ --
                    121: -- Testing fseek() without using argument whence --
                    122: int(-1)
                    123: int(0)
                    124: bool(false)
                    125: int(0)
                    126: int(0)
                    127: bool(false)
                    128: int(0)
                    129: int(1)
                    130: bool(false)
                    131: int(0)
                    132: int(513)
                    133: bool(false)
                    134: int(512)
                    135: -- File opened in mode w+b --
                    136: -- Testing fseek() without using argument whence --
                    137: int(-1)
                    138: int(0)
                    139: bool(false)
                    140: int(0)
                    141: int(0)
                    142: bool(false)
                    143: int(0)
                    144: int(1)
                    145: bool(false)
                    146: int(0)
                    147: int(513)
                    148: bool(false)
                    149: int(512)
                    150: -- File opened in mode w+t --
                    151: -- Testing fseek() without using argument whence --
                    152: int(-1)
                    153: int(0)
                    154: bool(false)
                    155: int(0)
                    156: int(0)
                    157: bool(false)
                    158: int(0)
                    159: int(1)
                    160: bool(false)
                    161: int(0)
                    162: int(513)
                    163: bool(false)
                    164: int(569)
                    165: -- File opened in mode x --
                    166: -- Testing fseek() without using argument whence --
                    167: int(-1)
                    168: int(0)
                    169: bool(false)
                    170: int(0)
                    171: int(0)
                    172: bool(false)
                    173: int(0)
                    174: int(1)
                    175: bool(false)
                    176: int(0)
                    177: int(513)
                    178: bool(false)
                    179: int(512)
                    180: -- File opened in mode xb --
                    181: -- Testing fseek() without using argument whence --
                    182: int(-1)
                    183: int(0)
                    184: bool(false)
                    185: int(0)
                    186: int(0)
                    187: bool(false)
                    188: int(0)
                    189: int(1)
                    190: bool(false)
                    191: int(0)
                    192: int(513)
                    193: bool(false)
                    194: int(512)
                    195: -- File opened in mode xt --
                    196: -- Testing fseek() without using argument whence --
                    197: int(-1)
                    198: int(0)
                    199: bool(false)
                    200: int(0)
                    201: int(0)
                    202: bool(false)
                    203: int(0)
                    204: int(1)
                    205: bool(false)
                    206: int(0)
                    207: int(513)
                    208: bool(false)
                    209: int(569)
                    210: -- File opened in mode x+ --
                    211: -- Testing fseek() without using argument whence --
                    212: int(-1)
                    213: int(0)
                    214: bool(false)
                    215: int(0)
                    216: int(0)
                    217: bool(false)
                    218: int(0)
                    219: int(1)
                    220: bool(false)
                    221: int(0)
                    222: int(513)
                    223: bool(false)
                    224: int(512)
                    225: -- File opened in mode x+b --
                    226: -- Testing fseek() without using argument whence --
                    227: int(-1)
                    228: int(0)
                    229: bool(false)
                    230: int(0)
                    231: int(0)
                    232: bool(false)
                    233: int(0)
                    234: int(1)
                    235: bool(false)
                    236: int(0)
                    237: int(513)
                    238: bool(false)
                    239: int(512)
                    240: -- File opened in mode x+t --
                    241: -- Testing fseek() without using argument whence --
                    242: int(-1)
                    243: int(0)
                    244: bool(false)
                    245: int(0)
                    246: int(0)
                    247: bool(false)
                    248: int(0)
                    249: int(1)
                    250: bool(false)
                    251: int(0)
                    252: int(513)
                    253: bool(false)
                    254: int(569)
                    255: 
                    256: -- File having data of type alphanumeric --
                    257: -- File opened in mode w --
                    258: -- Testing fseek() without using argument whence --
                    259: int(-1)
                    260: int(0)
                    261: bool(false)
                    262: int(0)
                    263: int(0)
                    264: bool(false)
                    265: int(0)
                    266: int(1)
                    267: bool(false)
                    268: int(0)
                    269: int(513)
                    270: bool(false)
                    271: int(512)
                    272: -- File opened in mode wb --
                    273: -- Testing fseek() without using argument whence --
                    274: int(-1)
                    275: int(0)
                    276: bool(false)
                    277: int(0)
                    278: int(0)
                    279: bool(false)
                    280: int(0)
                    281: int(1)
                    282: bool(false)
                    283: int(0)
                    284: int(513)
                    285: bool(false)
                    286: int(512)
                    287: -- File opened in mode wt --
                    288: -- Testing fseek() without using argument whence --
                    289: int(-1)
                    290: int(0)
                    291: bool(false)
                    292: int(0)
                    293: int(0)
                    294: bool(false)
                    295: int(0)
                    296: int(1)
                    297: bool(false)
                    298: int(0)
                    299: int(513)
                    300: bool(false)
                    301: int(512)
                    302: -- File opened in mode w+ --
                    303: -- Testing fseek() without using argument whence --
                    304: int(-1)
                    305: int(0)
                    306: bool(false)
                    307: int(0)
                    308: int(0)
                    309: bool(false)
                    310: int(0)
                    311: int(1)
                    312: bool(false)
                    313: int(0)
                    314: int(513)
                    315: bool(false)
                    316: int(512)
                    317: -- File opened in mode w+b --
                    318: -- Testing fseek() without using argument whence --
                    319: int(-1)
                    320: int(0)
                    321: bool(false)
                    322: int(0)
                    323: int(0)
                    324: bool(false)
                    325: int(0)
                    326: int(1)
                    327: bool(false)
                    328: int(0)
                    329: int(513)
                    330: bool(false)
                    331: int(512)
                    332: -- File opened in mode w+t --
                    333: -- Testing fseek() without using argument whence --
                    334: int(-1)
                    335: int(0)
                    336: bool(false)
                    337: int(0)
                    338: int(0)
                    339: bool(false)
                    340: int(0)
                    341: int(1)
                    342: bool(false)
                    343: int(0)
                    344: int(513)
                    345: bool(false)
                    346: int(512)
                    347: -- File opened in mode x --
                    348: -- Testing fseek() without using argument whence --
                    349: int(-1)
                    350: int(0)
                    351: bool(false)
                    352: int(0)
                    353: int(0)
                    354: bool(false)
                    355: int(0)
                    356: int(1)
                    357: bool(false)
                    358: int(0)
                    359: int(513)
                    360: bool(false)
                    361: int(512)
                    362: -- File opened in mode xb --
                    363: -- Testing fseek() without using argument whence --
                    364: int(-1)
                    365: int(0)
                    366: bool(false)
                    367: int(0)
                    368: int(0)
                    369: bool(false)
                    370: int(0)
                    371: int(1)
                    372: bool(false)
                    373: int(0)
                    374: int(513)
                    375: bool(false)
                    376: int(512)
                    377: -- File opened in mode xt --
                    378: -- Testing fseek() without using argument whence --
                    379: int(-1)
                    380: int(0)
                    381: bool(false)
                    382: int(0)
                    383: int(0)
                    384: bool(false)
                    385: int(0)
                    386: int(1)
                    387: bool(false)
                    388: int(0)
                    389: int(513)
                    390: bool(false)
                    391: int(512)
                    392: -- File opened in mode x+ --
                    393: -- Testing fseek() without using argument whence --
                    394: int(-1)
                    395: int(0)
                    396: bool(false)
                    397: int(0)
                    398: int(0)
                    399: bool(false)
                    400: int(0)
                    401: int(1)
                    402: bool(false)
                    403: int(0)
                    404: int(513)
                    405: bool(false)
                    406: int(512)
                    407: -- File opened in mode x+b --
                    408: -- Testing fseek() without using argument whence --
                    409: int(-1)
                    410: int(0)
                    411: bool(false)
                    412: int(0)
                    413: int(0)
                    414: bool(false)
                    415: int(0)
                    416: int(1)
                    417: bool(false)
                    418: int(0)
                    419: int(513)
                    420: bool(false)
                    421: int(512)
                    422: -- File opened in mode x+t --
                    423: -- Testing fseek() without using argument whence --
                    424: int(-1)
                    425: int(0)
                    426: bool(false)
                    427: int(0)
                    428: int(0)
                    429: bool(false)
                    430: int(0)
                    431: int(1)
                    432: bool(false)
                    433: int(0)
                    434: int(513)
                    435: bool(false)
                    436: int(512)
                    437: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>