2 /* Prototype: string tempnam ( string $dir, string $prefix );
3 Description: Create file with unique file name.
6 /* Trying to create the file in a dir with permissions from 0000 to 0777,
7 Allowable permissions: files are expected to be created in the input dir
8 Non-allowable permissions: files are expected to be created in '/tmp' dir
11 echo "*** Testing tempnam() with dir of permissions from 0000 to 0777 ***\n";
12 $file_path = dirname(__FILE__
);
13 $dir_name = $file_path."/tempnam_variation4";
14 $prefix = "tempnamVar4.";
18 for($mode = 0000; $mode <= 0777; $mode++
) {
22 chmod($dir_name, $mode);
23 $file_name = tempnam($dir_name, $prefix);
25 if(file_exists($file_name) ) {
26 if (realpath(dirname($file_name)) == realpath(sys_get_temp_dir())) {
27 $msg = " created in temp dir ";
29 else if (dirname($file_name) == $dir_name) {
30 $msg = " created in requested dir";
33 $msg = " created in unexpected dir";
40 print("FAILED: File is not created\n");
46 echo "*** Done ***\n";