Changeset 258

Show
Ignore:
Timestamp:
10/21/07 00:46:45 (9 months ago)
Author:
hans
Message:

#155 - Applying (slightly modified) patch submitted by Bruce Weirdan. Adding correct filesystem permission checking for deleting files. (May not be correct for NTFS, though...)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.3/classes/phing/system/io/FileSystem.php

    r227 r258  
    128128     */ 
    129129    abstract function fromURIPath($path); 
    130  
     130     
    131131    /* -- Path operations -- */ 
    132132 
     
    191191        } 
    192192    } 
    193  
     193         
     194    /** 
     195     * Whether file can be deleted. 
     196     * @param PhingFile $f 
     197     * @return boolean 
     198     */ 
     199    function canDelete(PhingFile $f) 
     200    { 
     201        clearstatcache();  
     202                $dir = dirname($f->getAbsolutePath());  
     203                return (bool) @is_writable($dir);  
     204    } 
     205     
    194206    /** 
    195207     * Return the time at which the file or directory denoted by the given 
  • branches/2.3/classes/phing/system/io/PhingFile.php

    r185 r258  
    531531    function delete() { 
    532532        $fs = FileSystem::getFileSystem(); 
    533         if ($fs->checkAccess($this, true) !== true) { 
    534             throw new IOException("No read access to " . $this->path."\n"); 
     533        if ($fs->canDelete($this) !== true) { 
     534            throw new IOException("Cannot delete " . $this->path . "\n");  
    535535        } 
    536536        return $fs->delete($this); 
  • branches/2.3/classes/phing/system/io/UnixFileSystem.php

    r123 r258  
    264264    } 
    265265     
     266    /** 
     267     * Whether file can be deleted. 
     268     * @param PhingFile $f 
     269     * @return boolean 
     270     */ 
     271    function canDelete(PhingFile $f)  
     272        {  
     273                @clearstatcache();  
     274                $dir = dirname($f->getAbsolutePath());  
     275                return (bool) @is_writable($dir);  
     276        } 
     277     
    266278} 
  • branches/2.3/classes/phing/system/io/Win32FileSystem.php

    r129 r258  
    473473    } 
    474474 
     475        /** 
     476     * Whether file can be deleted. 
     477     *  
     478     * This is currently returning whether the specified file is 
     479     * writable.  This is likely wrong for NTFS file systems, but 
     480     * I'm not sure whether PHP can see the NTFS delete perm ... 
     481     *  
     482     * @param PhingFile $f 
     483     * @return boolean 
     484     */ 
     485    abstract function canDelete(PhingFile $f); 
     486     
    475487} 
    476488