当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::remove方法代码示例

本文整理汇总了PHP中Filesystem::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::remove方法的具体用法?PHP Filesystem::remove怎么用?PHP Filesystem::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Filesystem的用法示例。


在下文中一共展示了Filesystem::remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processAvatar

 public static function processAvatar($model, $source, $type = "artist")
 {
     try {
         $fileSystem = new Filesystem();
         $alowSize = Yii::app()->params['imageSize'];
         $maxSize = max($alowSize);
         $folderMax = "s0";
         foreach ($alowSize as $folder => $size) {
             // Create folder by ID
             $fileSystem->mkdirs($model->getAvatarPath($model->id, $folder, true));
             @chmod($model->getAvatarPath($model->id, $folder, true), 0755);
             // Get link file by ID
             $savePath[$folder] = $model->getAvatarPath($model->id, $folder);
             if ($size == $maxSize) {
                 $folderMax = $folder;
             }
         }
         // Delete file if exists
         if (file_exists($savePath[$folder])) {
             $fileSystem->remove($savePath);
         }
         if (file_exists($source)) {
             list($width, $height) = getimagesize($source);
             $imgCrop = new ImageCrop($source, 0, 0, $width, $height);
             // aspect ratio for image size
             $aspectRatioW = $aspectRatioH = 1;
             if ($type == "video") {
                 $videoAspectRatio = Yii::app()->params['videoResolutionRate'];
                 list($aspectRatioW, $aspectRatioH) = explode(":", $videoAspectRatio);
             }
             $res = array();
             foreach ($savePath as $k => $v) {
                 $desWidth = $alowSize[$k];
                 $desHeight = round($alowSize[$k] * intval($aspectRatioH) / intval($aspectRatioW));
                 if (file_exists($v) && is_file($v)) {
                     @unlink($v);
                 }
                 if ($width > 4000) {
                     self::ImageCropPro($v, $source, $desWidth, $desHeight, 70);
                 } else {
                     if ($k == $folderMax) {
                         $imgCrop->resizeRatio($v, $desWidth, $desHeight, 70);
                     } else {
                         $imgCrop->resizeCrop($v, $desWidth, $desHeight, 70);
                     }
                 }
             }
             if ($type != "video") {
                 $fileSystem->remove($source);
             }
         }
     } catch (Exception $e) {
         $error = $e->getMessage();
     }
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:55,代码来源:AvatarHelper.php

示例2: testRemove

 function testRemove()
 {
     $dir = PhutilDirectoryFixture::newEmptyFixture();
     $root = realpath($dir->getPath());
     mkdir("{$root}/one");
     touch("{$root}/one/onefile");
     mkdir("{$root}/one/two");
     touch("{$root}/one/two/twofile");
     touch("{$root}/top");
     $this->watch($root);
     $this->assertFileList($root, array('one', 'one/onefile', 'one/two', 'one/two/twofile', 'top'));
     $this->watchmanCommand('log', 'debug', 'XXX: remove dir one');
     Filesystem::remove("{$root}/one");
     $this->assertFileList($root, array('top'));
     $this->watchmanCommand('log', 'debug', 'XXX: touch file one');
     touch("{$root}/one");
     $this->assertFileList($root, array('one', 'top'));
     $this->watchmanCommand('log', 'debug', 'XXX: unlink file one');
     unlink("{$root}/one");
     $this->assertFileList($root, array('top'));
     system("rm -rf {$root} ; mkdir -p {$root}/notme");
     if (PHP_OS == 'Linux' && getenv('TRAVIS')) {
         $this->assertSkipped('openvz and inotify unlinks == bad time');
     }
     $watches = $this->waitForWatchman(array('watch-list'), function ($list) use($root) {
         return !in_array($root, $list['roots']);
     });
     $this->assertEqual(false, in_array($root, $watches['roots']), "watch deleted");
 }
开发者ID:rogerwangzy,项目名称:watchman,代码行数:29,代码来源:remove.php

示例3: deleteDocumentsByHash

 protected function deleteDocumentsByHash(array $hashes)
 {
     $root = $this->getConfig('root');
     $cache = $this->getPublishCache();
     foreach ($hashes as $hash) {
         $paths = $cache->getAtomPathsFromCache($hash);
         foreach ($paths as $path) {
             $abs = $root . DIRECTORY_SEPARATOR . $path;
             Filesystem::remove($abs);
             // If the parent directory is now empty, clean it up.
             $dir = dirname($abs);
             while (true) {
                 if (!Filesystem::isDescendant($dir, $root)) {
                     // Directory is outside of the root.
                     break;
                 }
                 if (Filesystem::listDirectory($dir)) {
                     // Directory is not empty.
                     break;
                 }
                 Filesystem::remove($dir);
                 $dir = dirname($dir);
             }
         }
         $cache->removeAtomPathsFromCache($hash);
         $cache->deleteAtomFromIndex($hash);
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:28,代码来源:DivinerStaticPublisher.php

示例4: deleteFile

 /**
  * Deletes the file from local disk, if it exists.
  * @task impl
  */
 public function deleteFile($handle)
 {
     $path = $this->getLocalDiskFileStorageFullPath($handle);
     if (Filesystem::pathExists($path)) {
         Filesystem::remove($path);
     }
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:11,代码来源:PhabricatorLocalDiskFileStorageEngine.php

示例5: editInteractively

 /**
  * Launch an editor and edit the content. The edited content will be
  * returned.
  *
  * @return string    Edited content.
  * @throws Exception The editor exited abnormally or something untoward
  *                   occurred.
  *
  * @task edit
  */
 public function editInteractively()
 {
     $name = $this->getName();
     $content = $this->getContent();
     if (phutil_is_windows()) {
         $content = str_replace("\n", "\r\n", $content);
     }
     $tmp = Filesystem::createTemporaryDirectory('edit.');
     $path = $tmp . DIRECTORY_SEPARATOR . $name;
     try {
         Filesystem::writeFile($path, $content);
     } catch (Exception $ex) {
         Filesystem::remove($tmp);
         throw $ex;
     }
     $editor = $this->getEditor();
     $offset = $this->getLineOffset();
     $err = $this->invokeEditor($editor, $path, $offset);
     if ($err) {
         Filesystem::remove($tmp);
         throw new Exception("Editor exited with an error code (#{$err}).");
     }
     try {
         $result = Filesystem::readFile($path);
         Filesystem::remove($tmp);
     } catch (Exception $ex) {
         Filesystem::remove($tmp);
         throw $ex;
     }
     if (phutil_is_windows()) {
         $result = str_replace("\r\n", "\n", $result);
     }
     $this->setContent($result);
     return $this->getContent();
 }
开发者ID:lsubra,项目名称:libphutil,代码行数:45,代码来源:PhutilInteractiveEditor.php

示例6: deleteTmpDir

 protected function deleteTmpDir($testCase)
 {
     if (!file_exists($dir = sys_get_temp_dir() . '/' . Kernel::VERSION . '/' . $testCase)) {
         return;
     }
     $fs = new Filesystem();
     $fs->remove($dir);
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:8,代码来源:WebTestCase.php

示例7: deleteFile

 /**
  * Deletes the file from local disk, if it exists.
  * @task impl
  */
 public function deleteFile($handle)
 {
     $path = $this->getLocalDiskFileStorageFullPath($handle);
     if (Filesystem::pathExists($path)) {
         AphrontWriteGuard::willWrite();
         Filesystem::remove($path);
     }
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:12,代码来源:PhabricatorLocalDiskFileStorageEngine.php

示例8: __destruct

 public function __destruct()
 {
     Filesystem::remove($this->dir);
     // Note that the function tempnam() doesn't guarantee it will return a
     // file inside the dir you passed to the function.
     if (file_exists($this->file)) {
         unlink($this->file);
     }
 }
开发者ID:rmoorman,项目名称:libphutil,代码行数:9,代码来源:TempFile.php

示例9: processAvatar

 public static function processAvatar($id, $source, $type = "blog")
 {
     $fileSystem = new Filesystem();
     $alowSize = Yii::app()->params['imageSize']["{$type}"];
     $maxSize = max($alowSize);
     $folderMax = "s0";
     $pathDir = Yii::app()->params[$type . '_path'];
     foreach ($alowSize as $folder => $size) {
         // Create folder by ID
         $avatarPath = self::getAvatarPath($id, $folder, true, $pathDir);
         $fileSystem->mkdirs($avatarPath);
         @chmod($avatarPath, 0777);
         // Get link file by ID
         $savePath[$folder] = self::getAvatarPath($id, $folder, false, $pathDir);
         if ($size == $maxSize) {
             $folderMax = $folder;
         }
     }
     // Delete file if exists
     if (file_exists($savePath[$folder])) {
         $fileSystem->remove($savePath);
     }
     if (file_exists($source)) {
         list($width, $height) = getimagesize($source);
         $imgCrop = new ImageCrop($source, 0, 0, $width, $height);
         // aspect ratio for image size
         $aspectRatioW = $aspectRatioH = 1;
         foreach ($savePath as $k => $v) {
             $desWidth = $alowSize[$k];
             $desHeight = round($alowSize[$k] * intval($aspectRatioH) / intval($aspectRatioW));
             if (file_exists($v) && is_file($v)) {
                 @unlink($v);
             }
             if ($k == $folderMax) {
                 $imgCrop->resizeRatio($v, $desWidth, $desHeight, 100);
             } else {
                 $imgCrop->resizeCrop($v, $desWidth, $desHeight, 100);
             }
         }
         //remove file source
         $fileSystem->remove($source);
     }
 }
开发者ID:phuongitvn,项目名称:vdh,代码行数:43,代码来源:AvatarHelper.php

示例10: __destruct

 /**
  * When the object is destroyed, it destroys the temporary file. You can
  * change this behavior with @{method:setPreserveFile}.
  *
  * @task internal
  */
 public function __destruct()
 {
     if ($this->preserve) {
         return;
     }
     Filesystem::remove($this->dir);
     // NOTE: tempnam() doesn't guarantee it will return a file inside the
     // directory you passed to the function, so we make sure to nuke the file
     // explicitly.
     Filesystem::remove($this->file);
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:17,代码来源:TempFile.php

示例11: test_symlink_removal

 public function test_symlink_removal()
 {
     $test_dir = 'tests/test-data/symlinks';
     $test_link = $test_dir . '/points_nowhere';
     if (is_dir($test_dir)) {
         $this->rmdir_recursive($test_dir);
     }
     mkdir($test_dir);
     symlink("does_not_exist", $test_link);
     $fs = new Filesystem();
     $fs->remove($test_dir);
     $this->assertFalse(is_link($test_link) || is_file($test_link));
 }
开发者ID:alexanderwanyoike,项目名称:php-filesystem,代码行数:13,代码来源:FilesystemTest.php

示例12: cleanup

function cleanup($sig = '?')
{
    global $g_pidfile;
    if ($g_pidfile) {
        Filesystem::remove($g_pidfile);
        $g_pidfile = null;
    }
    global $g_future;
    if ($g_future) {
        $g_future->resolveKill();
        $g_future = null;
    }
    exit(1);
}
开发者ID:nexeck,项目名称:phabricator,代码行数:14,代码来源:aphlict_launcher.php

示例13: beforeScenario

 public function beforeScenario($event)
 {
     parent::beforeScenario($event);
     // @todo provide our own mail system to ameliorate ensuing ugliness.
     if ($event instanceof ScenarioEvent) {
         if ($event->getScenario()->hasTag('mail')) {
             if (module_exists('devel')) {
                 variable_set('mail_system', array('default-system' => 'DevelMailLog'));
             } else {
                 throw new \Exception('You must ensure that the devel module is enabled');
             }
             $fs = new \Filesystem();
             if ($mail_path = $event->getScenario()->getTitle()) {
                 $fs->remove('/tmp/' . $mail_path);
                 $fs->mkdir($mail_path);
             }
             variable_set('devel_debug_mail_directory', $mail_path);
             // NB: DevelMailLog is going to replace our separator with __.
             variable_set('devel_debug_mail_file_format', '%to::%subject');
             $this->mail = new \DevelMailLog();
         }
     }
     if (!$this->drupalSession) {
         $_SERVER['SERVER_SOFTWARE'] = 'foo';
         $this->drupalSession = (object) array('name' => session_name(), 'id' => session_id());
         $_SESSION['foo'] = 'bar';
         drupal_session_commit();
     }
     session_name($this->drupalSession->name);
     session_id($this->drupalSession->id);
     $_COOKIE[session_name()] = session_id();
     drupal_session_start();
     $base_url = getenv('DRUPAL_BASE_URL');
     if (!empty($base_url)) {
         $this->setMinkParameter('base_url', $base_url);
     }
     $userName = getenv('DRUPAL_BASIC_AUTH_USERNAME');
     $pass = getenv('DRUPAL_BASIC_AUTH_PASS');
     foreach (array('selenium2', 'goutte') as $session) {
         $session = $this->getMink()->getSession($session);
         $session->visit($this->locatePath('/index.php?foo=bar'));
         if (!empty($userName) && !empty($pass)) {
             $this->getMink()->getSession()->setBasicAuth($userName, $pass);
         }
     }
 }
开发者ID:promet,项目名称:drupal-behat-extension,代码行数:46,代码来源:PrometDrupalContext.php

示例14: testRemoveRoot

 function testRemoveRoot()
 {
     if (PHP_OS == 'Linux' && getenv('TRAVIS')) {
         $this->assertSkipped('openvz and inotify unlinks == bad time');
     }
     $dir = PhutilDirectoryFixture::newEmptyFixture();
     $top = realpath($dir->getPath());
     $root = "{$top}/root";
     mkdir($root);
     touch("{$root}/hello");
     $this->watch($root);
     $this->assertFileList($root, array('hello'));
     Filesystem::remove($root);
     $this->assertFileList($root, array());
     $watches = $this->waitForWatchman(array('watch-list'), function ($list) use($root) {
         return !in_array($root, $list['roots']);
     });
     $this->assertEqual(false, in_array($root, $watches['roots']), "watch deleted");
     mkdir($root);
     touch("{$root}/hello");
     $this->assertFileList($root, array());
 }
开发者ID:rogerwangzy,项目名称:watchman,代码行数:22,代码来源:rmroot.php

示例15: closeSocket

 private function closeSocket()
 {
     if ($this->socket) {
         @stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
         @fclose($this->socket);
         Filesystem::remove(self::getPathToSocket($this->workingCopy));
         $this->socket = null;
     }
 }
开发者ID:milindc2031,项目名称:Test,代码行数:9,代码来源:ArcanistHgProxyServer.php


注:本文中的Filesystem::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。