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


PHP IOHelper::deleteFolder方法代码示例

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


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

示例1: delete

 /**
  * @return bool
  */
 public function delete()
 {
     if (!IOHelper::deleteFolder($this->getRealPath())) {
         return false;
     }
     return true;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:10,代码来源:Folder.php

示例2: _cleanTempFiles

 /**
  * Remove any temp files and/or folders that might have been created.
  *
  * @param string $unzipFolder
  * @param string $handle
  *
  * @return null
  */
 private function _cleanTempFiles($unzipFolder, $handle)
 {
     $path = $handle == 'craft' ? craft()->path->getAppPath() : craft()->path->getPluginsPath() . $handle . '/';
     // Get rid of all the .bak files/folders.
     $filesToDelete = IOHelper::getFolderContents($path, true, ".*\\.bak\$");
     // Now delete any files/folders that were marked for deletion in the manifest file.
     $manifestData = UpdateHelper::getManifestData($unzipFolder, $handle);
     if ($manifestData) {
         foreach ($manifestData as $row) {
             if (UpdateHelper::isManifestVersionInfoLine($row)) {
                 continue;
             }
             $rowData = explode(';', $row);
             if ($rowData[1] == PatchManifestFileAction::Remove) {
                 if (UpdateHelper::isManifestLineAFolder($rowData[0])) {
                     $tempFilePath = UpdateHelper::cleanManifestFolderLine($rowData[0]);
                 } else {
                     $tempFilePath = $rowData[0];
                 }
                 $filesToDelete[] = $path . $tempFilePath;
             }
             // In case we did the whole app folder
             if ($rowData[0][0] == '*') {
                 $filesToDelete[] = rtrim(IOHelper::normalizePathSeparators($path), '/') . '.bak/';
             }
         }
         foreach ($filesToDelete as $fileToDelete) {
             if (IOHelper::fileExists($fileToDelete)) {
                 if (IOHelper::isWritable($fileToDelete)) {
                     Craft::log('Deleting file: ' . $fileToDelete, LogLevel::Info, true);
                     IOHelper::deleteFile($fileToDelete, true);
                     // If that was the last file in this folder, nuke the folder.
                     if (IOHelper::isFolderEmpty(IOHelper::getFolderName($fileToDelete))) {
                         IOHelper::deleteFolder(IOHelper::getFolderName($fileToDelete));
                     }
                 }
             } else {
                 if (IOHelper::folderExists($fileToDelete)) {
                     if (IOHelper::isWritable($fileToDelete)) {
                         Craft::log('Deleting .bak folder:' . $fileToDelete, LogLevel::Info, true);
                         IOHelper::clearFolder($fileToDelete, true);
                         IOHelper::deleteFolder($fileToDelete, true);
                     }
                 }
             }
         }
     }
     // Clear the temp folder.
     IOHelper::clearFolder(craft()->path->getTempPath(), true);
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:58,代码来源:Updater.php

示例3: _cleanTempFiles

 /**
  * Remove any temp files and/or folders that might have been created.
  *
  * @param string $unzipFolder
  *
  * @return null
  */
 private function _cleanTempFiles($unzipFolder)
 {
     $appPath = craft()->path->getAppPath();
     // Get rid of all the .bak files/folders.
     $filesToDelete = IOHelper::getFolderContents($appPath, true, ".*\\.bak\$");
     // Now delete any files/folders that were marked for deletion in the manifest file.
     $manifestData = UpdateHelper::getManifestData($unzipFolder);
     if ($manifestData) {
         foreach ($manifestData as $row) {
             if (UpdateHelper::isManifestVersionInfoLine($row)) {
                 continue;
             }
             $rowData = explode(';', $row);
             if ($rowData[1] == PatchManifestFileAction::Remove) {
                 if (UpdateHelper::isManifestLineAFolder($rowData[0])) {
                     $tempFilePath = UpdateHelper::cleanManifestFolderLine($rowData[0]);
                 } else {
                     $tempFilePath = $rowData[0];
                 }
                 $filesToDelete[] = $appPath . $tempFilePath;
             }
         }
         foreach ($filesToDelete as $fileToDelete) {
             if (IOHelper::fileExists($fileToDelete)) {
                 if (IOHelper::isWritable($fileToDelete)) {
                     Craft::log('Deleting file: ' . $fileToDelete, LogLevel::Info, true);
                     IOHelper::deleteFile($fileToDelete, true);
                 }
             } else {
                 if (IOHelper::folderExists($fileToDelete)) {
                     if (IOHelper::isWritable($fileToDelete)) {
                         Craft::log('Deleting .bak folder:' . $fileToDelete, LogLevel::Info, true);
                         IOHelper::clearFolder($fileToDelete, true);
                         IOHelper::deleteFolder($fileToDelete, true);
                     }
                 }
             }
         }
     }
     // Clear the temp folder.
     IOHelper::clearFolder(craft()->path->getTempPath(), true);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:49,代码来源:Updater.php

示例4: doFileUpdate

 /**
  * @param $manifestData
  * @param $sourceTempFolder
  * @param $handle
  *
  * @return bool
  */
 public static function doFileUpdate($manifestData, $sourceTempFolder, $handle)
 {
     if ($handle == 'craft') {
         $destDirectory = craft()->path->getAppPath();
         $sourceFileDirectory = 'app/';
     } else {
         $destDirectory = craft()->path->getPluginsPath() . $handle . '/';
         $sourceFileDirectory = '';
     }
     try {
         foreach ($manifestData as $row) {
             if (static::isManifestVersionInfoLine($row)) {
                 continue;
             }
             $folder = false;
             $rowData = explode(';', $row);
             if (static::isManifestLineAFolder($rowData[0])) {
                 $folder = true;
                 $tempPath = static::cleanManifestFolderLine($rowData[0]);
             } else {
                 $tempPath = $rowData[0];
             }
             $destFile = IOHelper::normalizePathSeparators($destDirectory . $tempPath);
             $sourceFile = IOHelper::getRealPath(IOHelper::normalizePathSeparators($sourceTempFolder . '/' . $sourceFileDirectory . $tempPath));
             switch (trim($rowData[1])) {
                 // update the file
                 case PatchManifestFileAction::Add:
                     if ($folder) {
                         Craft::log('Updating folder: ' . $destFile, LogLevel::Info, true);
                         $tempFolder = rtrim($destFile, '/') . StringHelper::UUID() . '/';
                         $tempTempFolder = rtrim($destFile, '/') . '-tmp/';
                         IOHelper::createFolder($tempFolder);
                         IOHelper::copyFolder($sourceFile, $tempFolder);
                         IOHelper::rename($destFile, $tempTempFolder);
                         IOHelper::rename($tempFolder, $destFile);
                         IOHelper::clearFolder($tempTempFolder);
                         IOHelper::deleteFolder($tempTempFolder);
                     } else {
                         Craft::log('Updating file: ' . $destFile, LogLevel::Info, true);
                         IOHelper::copyFile($sourceFile, $destFile);
                     }
                     break;
             }
         }
     } catch (\Exception $e) {
         Craft::log('Error updating files: ' . $e->getMessage(), LogLevel::Error);
         UpdateHelper::rollBackFileChanges($manifestData, $handle);
         return false;
     }
     return true;
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:58,代码来源:UpdateHelper.php

示例5: deleteUserPhoto

 /**
  * Deletes a user's photo.
  *
  * @param UserModel $user The user.
  *
  * @return null
  */
 public function deleteUserPhoto(UserModel $user)
 {
     $folder = craft()->path->getUserPhotosPath() . $user->username;
     if (IOHelper::folderExists($folder)) {
         IOHelper::deleteFolder($folder);
     }
     $record = UserRecord::model()->findById($user->id);
     $record->photo = null;
     $user->photo = null;
     $record->save();
 }
开发者ID:webremote,项目名称:craft_boilerplate,代码行数:18,代码来源:UsersService.php

示例6: actionSendSupportRequest


//.........这里部分代码省略.........
                     $zipFile = $this->_createZip();
                 }
                 if ($getHelpModel->attachLogs && IOHelper::folderExists(craft()->path->getLogPath())) {
                     // Grab it all.
                     $logFolderContents = IOHelper::getFolderContents(craft()->path->getLogPath());
                     foreach ($logFolderContents as $file) {
                         // Make sure it's a file.
                         if (IOHelper::fileExists($file)) {
                             Zip::add($zipFile, $file, craft()->path->getStoragePath());
                         }
                     }
                 }
                 if ($getHelpModel->attachDbBackup && IOHelper::folderExists(craft()->path->getDbBackupPath())) {
                     // Make a fresh database backup of the current schema/data. We want all data from all tables
                     // for debugging.
                     craft()->db->backup();
                     $backups = IOHelper::getLastModifiedFiles(craft()->path->getDbBackupPath(), 3);
                     foreach ($backups as $backup) {
                         if (IOHelper::getExtension($backup) == 'sql') {
                             Zip::add($zipFile, $backup, craft()->path->getStoragePath());
                         }
                     }
                 }
             }
             if ($getHelpModel->attachment) {
                 // If we don't have a zip file yet, create one now.
                 if (!$zipFile) {
                     $zipFile = $this->_createZip();
                 }
                 $tempFolder = craft()->path->getTempPath() . StringHelper::UUID() . '/';
                 if (!IOHelper::folderExists($tempFolder)) {
                     IOHelper::createFolder($tempFolder);
                 }
                 $tempFile = $tempFolder . $getHelpModel->attachment->getName();
                 $getHelpModel->attachment->saveAs($tempFile);
                 // Make sure it actually saved.
                 if (IOHelper::fileExists($tempFile)) {
                     Zip::add($zipFile, $tempFile, $tempFolder);
                 }
             }
             if ($getHelpModel->attachTemplates) {
                 // If we don't have a zip file yet, create one now.
                 if (!$zipFile) {
                     $zipFile = $this->_createZip();
                 }
                 if (IOHelper::folderExists(craft()->path->getLogPath())) {
                     // Grab it all.
                     $templateFolderContents = IOHelper::getFolderContents(craft()->path->getSiteTemplatesPath());
                     foreach ($templateFolderContents as $file) {
                         // Make sure it's a file.
                         if (IOHelper::fileExists($file)) {
                             $templateFolderName = IOHelper::getFolderName(craft()->path->getSiteTemplatesPath(), false);
                             $siteTemplatePath = craft()->path->getSiteTemplatesPath();
                             $tempPath = substr($siteTemplatePath, 0, strlen($siteTemplatePath) - strlen($templateFolderName) - 1);
                             Zip::add($zipFile, $file, $tempPath);
                         }
                     }
                 }
             }
             if ($zipFile) {
                 $requestParams['File1_sFilename'] = 'SupportAttachment-' . IOHelper::cleanFilename(craft()->getSiteName()) . '.zip';
                 $requestParams['File1_sFileMimeType'] = 'application/zip';
                 $requestParams['File1_bFileBody'] = base64_encode(IOHelper::getFileContents($zipFile));
                 // Bump the default timeout because of the attachment.
                 $hsParams['callTimeout'] = 120;
             }
             // Grab the license.key file.
             if (IOHelper::fileExists(craft()->path->getLicenseKeyPath())) {
                 $requestParams['File2_sFilename'] = 'license.key';
                 $requestParams['File2_sFileMimeType'] = 'text/plain';
                 $requestParams['File2_bFileBody'] = base64_encode(IOHelper::getFileContents(craft()->path->getLicenseKeyPath()));
             }
         } catch (\Exception $e) {
             Craft::log('Tried to attach debug logs to a support request and something went horribly wrong: ' . $e->getMessage(), LogLevel::Warning);
             // There was a problem zipping, so reset the params and just send the email without the attachment.
             $requestParams = $requestParamDefaults;
         }
         require_once craft()->path->getLibPath() . 'HelpSpotAPI.php';
         $hsapi = new \HelpSpotAPI($hsParams);
         $result = $hsapi->requestCreate($requestParams);
         if ($result) {
             if ($zipFile) {
                 if (IOHelper::fileExists($zipFile)) {
                     IOHelper::deleteFile($zipFile);
                 }
             }
             if ($tempFolder) {
                 IOHelper::clearFolder($tempFolder);
                 IOHelper::deleteFolder($tempFolder);
             }
             $success = true;
         } else {
             $hsErrors = array_filter(preg_split("/(\r\n|\n|\r)/", $hsapi->errors));
             $errors = array('Support' => $hsErrors);
         }
     } else {
         $errors = $getHelpModel->getErrors();
     }
     $this->renderTemplate('_components/widgets/GetHelp/response', array('success' => $success, 'errors' => JsonHelper::encode($errors), 'widgetId' => $widgetId));
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:101,代码来源:DashboardController.php

示例7: _deleteTemplates

 /**
  * Deletes template files from templates folder
  *
  * @return null
  */
 private function _deleteTemplates()
 {
     $craftTemplateFolder = realpath(CRAFT_TEMPLATES_PATH);
     $instaBlogTargetFolder = $craftTemplateFolder . '/blog';
     // Try nicely to delete files
     IOHelper::deleteFolder($instaBlogTargetFolder, true);
     // If folder remains try to force it.
     if (is_dir($instaBlogTargetFolder)) {
         @system('/bin/rm -rf ' . escapeshellarg($instaBlogTargetFolder));
     }
 }
开发者ID:lukeholder,项目名称:craft-instablog,代码行数:16,代码来源:InstaBlog_UninstallService.php

示例8: deleteSourceFolder

 /**
  * @inheritDoc BaseAssetSourceType::deleteSourceFolder()
  *
  * @param AssetFolderModel $parentFolder
  * @param string           $folderName
  *
  * @return bool
  */
 protected function deleteSourceFolder(AssetFolderModel $parentFolder, $folderName)
 {
     return IOHelper::deleteFolder($this->getSourceFileSystemPath() . $parentFolder->path . $folderName);
 }
开发者ID:nathanedwards,项目名称:cowfields.craft,代码行数:12,代码来源:LocalAssetSourceType.php

示例9: _cleanTempFiles

 /**
  * Remove any temp files and/or folders that might have been created.
  */
 private function _cleanTempFiles($unzipFolder)
 {
     // Get rid of all the .bak files/folders.
     $baks = IOHelper::getFolderContents(craft()->path->getAppPath(), true, ".*\\.bak\$");
     foreach ($baks as $bak) {
         if (IOHelper::fileExists($bak)) {
             if (IOHelper::isWritable($bak)) {
                 Craft::log('Deleting .bak file: ' . $bak, LogLevel::Info, true);
                 IOHelper::deleteFile($bak, true);
             }
         } else {
             if (IOHelper::folderExists($bak)) {
                 if (IOHelper::isWritable($bak)) {
                     Craft::log('Deleting .bak folder:' . $bak, LogLevel::Info, true);
                     IOHelper::clearFolder($bak, true);
                     IOHelper::deleteFolder($bak, true);
                 }
             }
         }
     }
     // Now delete any files/folders that were marked for deletion in the manifest file.
     $manifestData = UpdateHelper::getManifestData($unzipFolder);
     if ($manifestData) {
         foreach ($manifestData as $row) {
             if (UpdateHelper::isManifestVersionInfoLine($row)) {
                 continue;
             }
             $rowData = explode(';', $row);
             $folder = false;
             if (UpdateHelper::isManifestLineAFolder($rowData[0])) {
                 $folder = true;
                 $tempFilePath = UpdateHelper::cleanManifestFolderLine($rowData[0]);
             } else {
                 $tempFilePath = $rowData[0];
             }
             $fullPath = '';
             switch (trim($rowData[1])) {
                 // If the file/folder was set to be deleted, there is no backup and we go ahead and remove it now.
                 case PatchManifestFileAction::Remove:
                     if ($tempFilePath == '') {
                         $fullPath = IOHelper::normalizePathSeparators(craft()->path->getAppPath());
                     } else {
                         $fullPath = IOHelper::normalizePathSeparators(craft()->path->getAppPath() . $tempFilePath);
                     }
                     break;
             }
             // Delete any files/folders we backed up.
             if ($folder) {
                 if (($folder = IOHelper::getFolder($fullPath)) !== false) {
                     Craft::log('Deleting folder: ' . $folder->getRealPath(), LogLevel::Info, true);
                     $folder->delete();
                 }
             } else {
                 if (($file = IOHelper::getFile($fullPath)) !== false) {
                     Craft::log('Deleting file: ' . $file->getRealPath(), LogLevel::Info, true);
                     $file->delete();
                 }
             }
         }
     }
     // Clear the temp folder.
     IOHelper::clearFolder(craft()->path->getTempPath(), true);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:66,代码来源:Updater.php

示例10: deleteUserPhoto

 /**
  * Delete a user's photo.
  *
  * @param UserModel $user
  * @return void
  */
 public function deleteUserPhoto(UserModel $user)
 {
     $folder = craft()->path->getUserPhotosPath() . $user->username;
     if (IOHelper::folderExists($folder)) {
         IOHelper::deleteFolder($folder);
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:13,代码来源:UsersService.php

示例11: actionSendSupportRequest


//.........这里部分代码省略.........
             if (!IOHelper::folderExists($tempFolder)) {
                 IOHelper::createFolder($tempFolder);
             }
             //
             // Attached just the Feed Me log
             //
             if ($getHelpModel->attachLogs) {
                 if (IOHelper::folderExists(craft()->path->getLogPath())) {
                     $logFolderContents = IOHelper::getFolderContents(craft()->path->getLogPath());
                     foreach ($logFolderContents as $file) {
                         // Just grab the Feed Me log
                         if (IOHelper::fileExists($file) && basename($file) == 'feedme.log') {
                             Zip::add($zipFile, $file, craft()->path->getStoragePath());
                         }
                     }
                 }
             }
             //
             // Backup our feed settings
             //
             if ($getHelpModel->attachSettings) {
                 if (IOHelper::folderExists(craft()->path->getDbBackupPath())) {
                     $backup = craft()->path->getDbBackupPath() . StringHelper::toLowerCase('feedme_' . gmdate('ymd_His') . '.sql');
                     $feedInfo = $this->_prepareSqlFeedSettings($getHelpModel->feedIssue);
                     IOHelper::writeToFile($backup, $feedInfo . PHP_EOL, true, true);
                     Zip::add($zipFile, $backup, craft()->path->getStoragePath());
                 }
             }
             //
             // Save the contents of the feed
             //
             if ($getHelpModel->attachFeed) {
                 $feedData = craft()->feedMe_feed->getRawData($feed->feedUrl);
                 $tempFile = $tempFolder . 'feed.' . StringHelper::toLowerCase($feed->feedType);
                 IOHelper::writeToFile($tempFile, $feedData . PHP_EOL, true, true);
                 if (IOHelper::fileExists($tempFile)) {
                     Zip::add($zipFile, $tempFile, $tempFolder);
                 }
             }
             //
             // Get some information about the fields we're mapping to - handy to know
             //
             if ($getHelpModel->attachFields) {
                 $fieldInfo = array();
                 foreach ($feed->fieldMapping as $feedHandle => $fieldHandle) {
                     $field = craft()->fields->getFieldByHandle($fieldHandle);
                     if ($field) {
                         $fieldInfo[] = $this->_prepareExportField($field);
                     }
                 }
                 // Support PHP <5.4, JSON_PRETTY_PRINT = 128, JSON_NUMERIC_CHECK = 32
                 $json = json_encode($fieldInfo, 128 | 32);
                 $tempFile = $tempFolder . 'fields.json';
                 IOHelper::writeToFile($tempFile, $json . PHP_EOL, true, true);
                 if (IOHelper::fileExists($tempFile)) {
                     Zip::add($zipFile, $tempFile, $tempFolder);
                 }
             }
             //
             // Add in any additional attachments
             //
             if ($getHelpModel->attachment) {
                 $tempFile = $tempFolder . $getHelpModel->attachment->getName();
                 $getHelpModel->attachment->saveAs($tempFile);
                 // Make sure it actually saved.
                 if (IOHelper::fileExists($tempFile)) {
                     Zip::add($zipFile, $tempFile, $tempFolder);
                 }
             }
         } catch (\Exception $e) {
             FeedMePlugin::log('Tried to attach debug logs to a support request and something went horribly wrong: ' . $e->getMessage(), LogLevel::Warning, true);
         }
         $email = new EmailModel();
         $email->fromEmail = $getHelpModel->fromEmail;
         $email->toEmail = "web@sgroup.com.au";
         $email->subject = "Feed Me Support";
         $email->body = $message;
         if ($zipFile) {
             $email->addAttachment($zipFile, 'FeedMeSupportAttachment.zip', 'base64', 'application/zip');
         }
         $result = craft()->email->sendEmail($email);
         if ($result) {
             if ($zipFile) {
                 if (IOHelper::fileExists($zipFile)) {
                     IOHelper::deleteFile($zipFile);
                 }
             }
             if ($tempFolder) {
                 IOHelper::clearFolder($tempFolder);
                 IOHelper::deleteFolder($tempFolder);
             }
             $success = true;
         } else {
             $errors = array('Support' => array('Unable to contact support. Please try again soon.'));
         }
     } else {
         $errors = $getHelpModel->getErrors();
     }
     $this->returnJson(array('success' => $success, 'errors' => $errors));
 }
开发者ID:EP-NY,项目名称:FeedMe,代码行数:101,代码来源:FeedMe_SupportController.php


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