Package: php-pclzip / 2.8.2-4

0001-Modified-temporary-directory.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From: Federico Gimenez Nieto <fgimenez@coit.es>
Date: Thu, 25 Feb 2010 12:50:23 +0100
Subject: Modified temporary directory

Change from current directory to TMPDIR environment variable
(defaults to /tmp)
---
 pclzip.lib.php | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/pclzip.lib.php b/pclzip.lib.php
index 4bf05a5..a9c76e7 100644
--- a/pclzip.lib.php
+++ b/pclzip.lib.php
@@ -63,7 +63,15 @@
   // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
   // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
   if (!defined('PCLZIP_TEMPORARY_DIR')) {
-    define( 'PCLZIP_TEMPORARY_DIR', '' );
+    // Attempt to honour the TMPDIR environment variable, defaulting to /tmp/
+    $tmp_dir=getenv( 'TMPDIR' );
+    if(empty( $tmp_dir ))
+      $tmp_dir = "/tmp/";
+    // Perhaps TMPDIR is not defined with a trailing slash
+    else if( substr( $tmp_dir, -1 ) != '/')
+      $tmp_dir.="/";
+
+    define( 'PCLZIP_TEMPORARY_DIR', $tmp_dir );
   }
 
   // ----- Optional threshold ratio for use of temporary files