PHP Classes

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

Recommend this page to a friend!

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

  1. When $dirname equals '.', directory...   Reply   Report abuse  
Ben Johnson - 2010-07-29 18:43:44
Line 242 of contains:

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

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


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/"

the command will fail with "mkdir: cannot create directory `/var/www/vhosts/': 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){


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 =).