create() 공개 메소드

create the directory
부터: 3.0.0
public create ( string $directory = null, integer $mode = 511 )
$directory string name of the directory
$mode integer file access mode
예제 #1
0
 /**
  * setUpBeforeClass
  *
  * @since 3.0.0
  */
 public static function setUpBeforeClass()
 {
     $rootDirectory = new Directory();
     $rootDirectory->init('.');
     $rootDirectory->create('.restore');
     $rootDirectory->put('.restore/test.sql', '/* test */');
 }
 /**
  * testCreate
  *
  * @since 2.1.0
  *
  * @param array $path
  * @param array $expect
  *
  * @dataProvider providerCreate
  */
 public function testCreate($path = array(), $expect = array())
 {
     /* setup */
     $directory = new Directory();
     $directory->init(Stream::url($path[1]));
     $directory->create($path[0], 511);
     /* actual */
     $actual = scandir(Stream::url($path[2]));
     /* compare */
     $this->assertEquals($expect, $actual);
 }
예제 #3
0
 /**
  * testCreate
  *
  * @since 3.0.0
  *
  * @param string $path
  * @param string $create
  * @param array $expectArray
  *
  * @dataProvider providerCreate
  */
 public function testCreate($path = null, $create = null, $expectArray = [])
 {
     /* setup */
     $directory = new Directory();
     $directory->init(Stream::url($path));
     $directory->create($create, 0777);
     /* actual */
     $actualArray = scandir(Stream::url($path));
     /* compare */
     $this->assertEquals($expectArray, $actualArray);
 }
예제 #4
0
 /**
  * createThumb
  *
  * @since 3.0.0
  *
  * @param string $directory
  * @param array $optionArray
  *
  * @return string
  */
 protected static function _createThumb($directory = null, $optionArray = [])
 {
     /* gallery directory */
     $galleryDirectory = new Directory();
     $galleryDirectory->init($directory, [self::$_configArray['thumbDirectory']]);
     $galleryDirectory->create(self::$_configArray['thumbDirectory']);
     $galleryDirectoryArray = $galleryDirectory->getArray();
     /* process directory */
     if (chmod($directory . '/' . self::$_configArray['thumbDirectory'], 0777)) {
         foreach ($galleryDirectoryArray as $value) {
             $imagePath = $directory . '/' . $value;
             $imageExtension = strtolower(pathinfo($value, PATHINFO_EXTENSION));
             $thumbPath = $directory . '/' . self::$_configArray['thumbDirectory'] . '/' . $value;
             /* switch extension */
             switch ($imageExtension) {
                 case 'gif':
                     $image = imagecreatefromgif($imagePath);
                     break;
                 case 'jpg':
                     $image = imagecreatefromjpeg($imagePath);
                     break;
                 case 'png':
                     $image = imagecreatefrompng($imagePath);
                     break;
                 default:
                     $image = null;
             }
             /* source and dist */
             $sourceArray = self::_calcSource($imagePath);
             $distArray = self::_calcDist($sourceArray, $optionArray);
             /* create thumb files */
             $thumb = imagecreatetruecolor($distArray['width'], $distArray['height']);
             imagecopyresampled($thumb, $image, 0, 0, 0, 0, $distArray['width'], $distArray['height'], $sourceArray['width'], $sourceArray['height']);
             imagejpeg($thumb, $thumbPath, $distArray['quality']);
             /* destroy image */
             imagedestroy($thumb);
             imagedestroy($image);
         }
     } else {
         self::setNotification('error', Language::get('directory_permission_grant') . Language::get('colon') . ' ' . $directory . '/' . self::$_configArray['thumbDirectory'] . Language::get('point'));
     }
 }