lib/Util/Archive/FileAdder.php
public function addFileFromBasedir($pathname, $basedir = '')
    {
        $info = new \SplFileInfo($pathname);

        if (!$info->isFile())
        {
            throw new InvalidArgumentException(sprintf('File not found: %s', $pathname));
        }

        if (!$info->isReadable())
        {
            throw new InvalidArgumentException(sprintf('File not readable: %s', $pathname));
        }

        $relativePathname = $this->subtractBasedir($pathname, $basedir);
        #echo sprintf("%s\n", $relativePathname);

        if ($basedir && $pathname === '/' . $relativePathname)
        {
            throw new InvalidArgumentException(sprintf('Invalid basedir: %s', $basedir));
        }

        $this->zip->addFile($pathname, $relativePathname);
    }
public function addFileFromBasedir($pathname, $basedir = '')
    {
        $info = new \SplFileInfo($pathname);

        if (!$info->isFile())
        {
            throw new InvalidArgumentException(sprintf('File not found: %s', $pathname));
        }

        if (!$info->isReadable())
        {
            throw new InvalidArgumentException(sprintf('File not readable: %s', $pathname));
        }

        $relativePathname = $this->subtractBasedir($pathname, $basedir);
        #echo sprintf("%s\n", $relativePathname);

        if ($basedir && $pathname === '/' . $relativePathname)
        {
            throw new InvalidArgumentException(sprintf('Invalid basedir: %s', $basedir));
        }

        $this->zip->addFile($pathname, $relativePathname);
    }
public function addFileFromBasedir ( $ pathname , $ basedir = '' ) { $ info = new \ SplFileInfo ( $ pathname ) ; if ( ! $ info -> isFile ( ) ) { throw new InvalidArgumentException ( sprintf ( 'File not found: %s' , $ pathname ) ) ; } if ( ! $ info -> isReadable ( ) ) { throw new InvalidArgumentException ( sprintf ( 'File not readable: %s' , $ pathname ) ) ; } $ relativePathname = $ this -> subtractBasedir ( $ pathname , $ basedir ) ; #echo sprintf("%s\n", $relativePathname); if ( $ basedir && $ pathname === '/' . $ relativePathname ) { throw new InvalidArgumentException ( sprintf ( 'Invalid basedir: %s' , $ basedir ) ) ; } $ this -> zip -> addFile ( $ pathname , $ relativePathname ) ; }
Calculate relative pathname within archive and add file

@example Pathname of '/share/lib/readme.md' and basedir of '/share' will add 'lib/readme.md' to archive

@param string $pathname The full pathname
@param string $baseDir The base pathname within pathname
Calculate relative pathname within archive and add file