Create post-HADVAs expect files
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / file / tempnam_variation6.php
blobbfaf6071b018ba99268af9b28affac1568d9a6c8
1 <?hh
2 /* Prototype: string tempnam ( string $dir, string $prefix );
3 Description: Create file with unique file name.
4 */
6 /* Trying to create unique files by passing previously created unique file name as prefix */
7 <<__EntryPoint>> function main(): void {
8 $file_path = __SystemLib\hphp_test_tmppath('sandbox');
9 mkdir($file_path);
11 echo "\n*** Test tempnam(): by passing previously created filenames ***\n";
12 $file_name = "tempnam_variation6.tmp";
13 for($i=1; $i<=3; $i++) {
14 echo "-- Iteration $i --\n";
15 $file_name = tempnam("$file_path", $file_name);
17 if( file_exists($file_name) ) {
18 echo "File name is => ";
19 print($file_name);
20 echo "\n";
22 echo "File created in => ";
23 $file_dir = dirname($file_name);
25 if ($file_dir == sys_get_temp_dir()) {
26 echo "temp dir\n";
28 else if ($file_dir == $file_path) {
29 echo "directory specified\n";
31 else {
32 echo "unknown location\n";
36 unlink($file_name);
39 echo "\n*** Done ***\n";
41 rmdir($file_path);