Annotation of embedaddon/php/ext/standard/tests/file/tempnam_variation1-win32.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test tempnam() function: usage variations - creating files
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: string tempnam ( string $dir, string $prefix );
11: Description: Create file with unique file name.
12: */
13:
14: /* Creating number of unique files by passing a file name as prefix */
15:
16: $file_path = dirname(__FILE__)."/tempnamVar1";
17: mkdir($file_path);
18:
19: echo "*** Testing tempnam() in creation of unique files ***\n";
20: for($i=1; $i<=10; $i++) {
21: echo "-- Iteration $i --\n";
22: $files[$i] = tempnam("$file_path", "tempnam_variation1.tmp");
23:
24: if( file_exists($files[$i]) ) {
25:
26: echo "File name is => ";
27: print($files[$i]);
28: echo "\n";
29:
30: echo "File permissions are => ";
31: printf("%o", fileperms($files[$i]) );
32: echo "\n";
33: clearstatcache();
34:
35: echo "File created in => ";
36: $file_dir = dirname($files[$i]);
37:
38: if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
39: echo "temp dir\n";
40: }
41: else if (realpath($file_dir) == realpath($file_path) || realpath($file_dir."\\") == realpath($file_path)) {
42: echo "directory specified\n";
43: }
44: else {
45: echo "unknown location\n";
46: }
47: clearstatcache();
48: }
49: else {
50: print("- File is not created -");
51: }
52: }
53: for($i=1; $i<=10; $i++) {
54: unlink($files[$i]);
55: }
56: rmdir($file_path);
57:
58:
59: echo "*** Done ***\n";
60: ?>
61: --EXPECTF--
62: *** Testing tempnam() in creation of unique files ***
63: -- Iteration 1 --
64: File name is => %s%et%s
65: File permissions are => 100666
66: File created in => directory specified
67: -- Iteration 2 --
68: File name is => %s%et%s
69: File permissions are => 100666
70: File created in => directory specified
71: -- Iteration 3 --
72: File name is => %s%et%s
73: File permissions are => 100666
74: File created in => directory specified
75: -- Iteration 4 --
76: File name is => %s%et%s
77: File permissions are => 100666
78: File created in => directory specified
79: -- Iteration 5 --
80: File name is => %s%et%s
81: File permissions are => 100666
82: File created in => directory specified
83: -- Iteration 6 --
84: File name is => %s%et%s
85: File permissions are => 100666
86: File created in => directory specified
87: -- Iteration 7 --
88: File name is => %s%et%s
89: File permissions are => 100666
90: File created in => directory specified
91: -- Iteration 8 --
92: File name is => %s%et%s
93: File permissions are => 100666
94: File created in => directory specified
95: -- Iteration 9 --
96: File name is => %s%et%s
97: File permissions are => 100666
98: File created in => directory specified
99: -- Iteration 10 --
100: File name is => %s%et%s
101: File permissions are => 100666
102: File created in => directory specified
103: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>