Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / resources / portabilityLayer.php
blobe2fdc2d51e9d47d52f3b82e34cb1c0b0544567dd
1 <?php
3 if (!function_exists('sys_get_temp_dir')) {
4 // Based on http://www.phpit.net/article/creating-zip-tar-archives-dynamically-php/2/
5 // If the builtin PHP sys_get_temp_dir doesn't exist, we replace it with one that will
6 // try to guess from the environment. Since sys_get_temp_dir() doesn't return a trailing
7 // slash on all system (see comment at http://us.php.net/sys_get_temp_dir), we don't
8 // append a trailing slash, and expect callers to append one when needed.
9 function sys_get_temp_dir()
11 // Try to get from environment variable
12 if (!empty($_ENV['TMP']))
13 return realpath($_ENV['TMP']);
14 if (!empty($_ENV['TMPDIR']))
15 return realpath($_ENV['TMPDIR']);
16 if (!empty($_ENV['TEMP']))
17 return realpath( $_ENV['TEMP']);
18 return "/tmp";
22 if (!function_exists('file_put_contents')) {
23 function file_put_contents($filename, $data)
25 $handle = fopen($filename, "w");
26 if (!$handle)
27 return FALSE;
28 $bytesWritten = fwrite($handle, $data);
29 if (!fclose($handle))
30 return FALSE;
31 return $bytesWritten;