1--TEST-- 2Userstream unlink, rename, mkdir, rmdir, and url_stat. 3--FILE-- 4<?php 5class test { 6 public $context; 7 8 function unlink($file) { 9 print "Unlinking file: $file\n"; 10 } 11 12 function rename($from, $to) { 13 print "Renaming $from to $to\n"; 14 } 15 16 function mkdir($directory, $mode, $options) { 17 printf("Making directory: %s as %o%s\n", $directory, $mode, $options & STREAM_MKDIR_RECURSIVE ? " recursively" : ""); 18 } 19 20 function rmdir($directory, $options) { 21 print "Removing directory: $directory\n"; 22 } 23 24 function url_stat($path, $options) { 25 /* By printing out a notice that we are actively stating the file 26 then subsequently performing multiple stat operations on it 27 we effectively test the stat cache mechanism */ 28 print "Stating file: $path\n"; 29 return array('dev'=>1, 'ino'=>2, 'mode'=>0644, 'nlink'=>3, 30 'uid'=>100, 'gid'=>1000, 'rdev'=>-1, 'size'=>31337, 31 'atime'=>1234567890, 'mtime'=>1231231231, 'ctime'=>1234564564, 32 'blksize'=>-1, 'blocks'=>-1); 33 } 34} 35 36stream_wrapper_register('test', 'test'); 37 38unlink('test://example.com/path/to/file'); 39rename('test://example.com/path/to/from', 'test://example.com/path/to/to'); 40/* We *want* this to fail and thus not output the watch statement */ 41@rename('test://example.com/path/to/from', 'http://example.com/path/to/to'); 42mkdir('test://example.com/path/to/directory', 0755); 43rmdir('test://example.com/path/to/directory'); 44print_r(stat('test://example.com/path/to/file')); 45echo "Filesize = " . filesize('test://example.com/path/to/file') . "\n"; 46echo "filemtime = " . filemtime('test://example.com/path/to/file') . "\n"; 47?> 48--EXPECT-- 49Unlinking file: test://example.com/path/to/file 50Renaming test://example.com/path/to/from to test://example.com/path/to/to 51Making directory: test://example.com/path/to/directory as 755 52Removing directory: test://example.com/path/to/directory 53Stating file: test://example.com/path/to/file 54Array 55( 56 [0] => 1 57 [1] => 2 58 [2] => 420 59 [3] => 3 60 [4] => 100 61 [5] => 1000 62 [6] => -1 63 [7] => 31337 64 [8] => 1234567890 65 [9] => 1231231231 66 [10] => 1234564564 67 [11] => -1 68 [12] => -1 69 [dev] => 1 70 [ino] => 2 71 [mode] => 420 72 [nlink] => 3 73 [uid] => 100 74 [gid] => 1000 75 [rdev] => -1 76 [size] => 31337 77 [atime] => 1234567890 78 [mtime] => 1231231231 79 [ctime] => 1234564564 80 [blksize] => -1 81 [blocks] => -1 82) 83Filesize = 31337 84filemtime = 1231231231 85