Login   Register  
PHP Classes
elePHPant
Icontem

When $dirname equals '.', directory creations fails on POSIX sys

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      dUnzip2  >  All threads  >  When $dirname equals '.', directory creations fails on POSIX sys  >  (Un) Subscribe thread alerts  
Subject:When $dirname equals '.', directory creations fails on POSIX sys
Summary:v 2.66 does not function "out-of-the-box" on POSIX systems
Messages:1
Author:Ben Johnson
Date:2010-07-29 18:43:44
 

  1. When $dirname equals '.', directory creations fails on POSIX sys   Reply  
Picture of Ben Johnson
Ben Johnson
2010-07-29 18:43:44
Line 242 of dUnzip2.inc.php contains:

$dirname = ($dirname!='.')?dirname($fileName):'';

When $dirname DOES equal the period character ('.'), line 255, which contains

mkdir("$targetDir/$str");

throws an error on POSIX systems. The reason appears to be that the argument to the mkdir() call contains a trailing '/.' in those cases.

If one attempts to call mkdir() on a UNIX-like system, using a path that ends with '/.', for example

mkdir "/var/www/vhosts/newsite.com/."

the command will fail with "mkdir: cannot create directory `/var/www/vhosts/newsite.com/.': No such file or directory".

A simple fix is to wrap the foreach statement on line 241

if(sizeof($lista)) foreach($lista as $fileName=>$trash){

with

if ($fileName != '.') {
//Existing foreach loop is moved here.
}

I do not know what other implications such a modification may have on the script's existing functionality, so make this change at your own risk =).