2007-08-09 03:34:00 +00:00
|
|
|
--TEST--
|
|
|
|
Test tempnam() function: usage variations - creating files
|
|
|
|
--SKIPIF--
|
|
|
|
<?php
|
|
|
|
if(substr(PHP_OS, 0, 3) != "WIN")
|
2008-11-26 10:10:19 +00:00
|
|
|
die("skip Only valid for Windows");
|
2007-08-09 03:34:00 +00:00
|
|
|
?>
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
/* Prototype: string tempnam ( string $dir, string $prefix );
|
|
|
|
Description: Create file with unique file name.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Creating number of unique files by passing a file name as prefix */
|
|
|
|
|
2008-11-26 10:10:19 +00:00
|
|
|
$file_path = dirname(__FILE__)."/tempnamVar1";
|
|
|
|
mkdir($file_path);
|
2007-08-09 03:34:00 +00:00
|
|
|
|
|
|
|
echo "*** Testing tempnam() in creation of unique files ***\n";
|
|
|
|
for($i=1; $i<=10; $i++) {
|
|
|
|
echo "-- Iteration $i --\n";
|
|
|
|
$files[$i] = tempnam("$file_path", "tempnam_variation1.tmp");
|
|
|
|
|
|
|
|
if( file_exists($files[$i]) ) {
|
|
|
|
|
|
|
|
echo "File name is => ";
|
|
|
|
print($files[$i]);
|
|
|
|
echo "\n";
|
|
|
|
|
|
|
|
echo "File permissions are => ";
|
|
|
|
printf("%o", fileperms($files[$i]) );
|
|
|
|
echo "\n";
|
|
|
|
clearstatcache();
|
|
|
|
|
2008-11-26 10:10:19 +00:00
|
|
|
echo "File created in => ";
|
|
|
|
$file_dir = dirname($files[$i]);
|
|
|
|
|
|
|
|
if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
|
|
|
|
echo "temp dir\n";
|
|
|
|
}
|
|
|
|
else if (realpath($file_dir) == realpath($file_path) || realpath($file_dir."\\") == realpath($file_path)) {
|
|
|
|
echo "directory specified\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo "unknown location\n";
|
|
|
|
}
|
|
|
|
clearstatcache();
|
2007-08-09 03:34:00 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
print("- File is not created -");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for($i=1; $i<=10; $i++) {
|
|
|
|
unlink($files[$i]);
|
|
|
|
}
|
2008-11-26 10:10:19 +00:00
|
|
|
rmdir($file_path);
|
|
|
|
|
2007-08-09 03:34:00 +00:00
|
|
|
|
|
|
|
echo "*** Done ***\n";
|
2007-08-10 12:11:46 +00:00
|
|
|
?>
|
2007-08-09 03:34:00 +00:00
|
|
|
--EXPECTF--
|
|
|
|
*** Testing tempnam() in creation of unique files ***
|
|
|
|
-- Iteration 1 --
|
2008-11-26 10:10:19 +00:00
|
|
|
File name is => %s%et%s
|
2007-08-09 03:34:00 +00:00
|
|
|
File permissions are => 100666
|
2008-11-26 10:10:19 +00:00
|
|
|
File created in => directory specified
|
2007-08-09 03:34:00 +00:00
|
|
|
-- Iteration 2 --
|
2008-11-26 10:10:19 +00:00
|
|
|
File name is => %s%et%s
|
2007-08-09 03:34:00 +00:00
|
|
|
File permissions are => 100666
|
2008-11-26 10:10:19 +00:00
|
|
|
File created in => directory specified
|
2007-08-09 03:34:00 +00:00
|
|
|
-- Iteration 3 --
|
2008-11-26 10:10:19 +00:00
|
|
|
File name is => %s%et%s
|
2007-08-09 03:34:00 +00:00
|
|
|
File permissions are => 100666
|
2008-11-26 10:10:19 +00:00
|
|
|
File created in => directory specified
|
2007-08-09 03:34:00 +00:00
|
|
|
-- Iteration 4 --
|
2008-11-26 10:10:19 +00:00
|
|
|
File name is => %s%et%s
|
2007-08-09 03:34:00 +00:00
|
|
|
File permissions are => 100666
|
2008-11-26 10:10:19 +00:00
|
|
|
File created in => directory specified
|
2007-08-09 03:34:00 +00:00
|
|
|
-- Iteration 5 --
|
2008-11-26 10:10:19 +00:00
|
|
|
File name is => %s%et%s
|
2007-08-09 03:34:00 +00:00
|
|
|
File permissions are => 100666
|
2008-11-26 10:10:19 +00:00
|
|
|
File created in => directory specified
|
2007-08-09 03:34:00 +00:00
|
|
|
-- Iteration 6 --
|
2008-11-26 10:10:19 +00:00
|
|
|
File name is => %s%et%s
|
2007-08-09 03:34:00 +00:00
|
|
|
File permissions are => 100666
|
2008-11-26 10:10:19 +00:00
|
|
|
File created in => directory specified
|
2007-08-09 03:34:00 +00:00
|
|
|
-- Iteration 7 --
|
2008-11-26 10:10:19 +00:00
|
|
|
File name is => %s%et%s
|
2007-08-09 03:34:00 +00:00
|
|
|
File permissions are => 100666
|
2008-11-26 10:10:19 +00:00
|
|
|
File created in => directory specified
|
2007-08-09 03:34:00 +00:00
|
|
|
-- Iteration 8 --
|
2008-11-26 10:10:19 +00:00
|
|
|
File name is => %s%et%s
|
2007-08-09 03:34:00 +00:00
|
|
|
File permissions are => 100666
|
2008-11-26 10:10:19 +00:00
|
|
|
File created in => directory specified
|
2007-08-09 03:34:00 +00:00
|
|
|
-- Iteration 9 --
|
2008-11-26 10:10:19 +00:00
|
|
|
File name is => %s%et%s
|
2007-08-09 03:34:00 +00:00
|
|
|
File permissions are => 100666
|
2008-11-26 10:10:19 +00:00
|
|
|
File created in => directory specified
|
2007-08-09 03:34:00 +00:00
|
|
|
-- Iteration 10 --
|
2008-11-26 10:10:19 +00:00
|
|
|
File name is => %s%et%s
|
2007-08-09 03:34:00 +00:00
|
|
|
File permissions are => 100666
|
2008-11-26 10:10:19 +00:00
|
|
|
File created in => directory specified
|
2007-08-09 03:34:00 +00:00
|
|
|
*** Done ***
|