本文整理汇总了PHP中Cake\Filesystem\Folder::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::delete方法的具体用法?PHP Folder::delete怎么用?PHP Folder::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Filesystem\Folder
的用法示例。
在下文中一共展示了Folder::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
$Folder = new Folder($this->Task->path . 'BakeTestApp');
$Folder->delete();
unset($this->Task);
}
示例2: tearDown
/**
* @return void
*/
public function tearDown()
{
parent::tearDown();
$dir = new Folder(TMP . 'lock');
$dir->delete();
unset($this->Lock);
}
示例3: tearDown
public function tearDown()
{
parent::tearDown();
$testPluginFolder = new Folder(ROOT . DS . 'plugins' . DS . 'PluginInstallerTest');
$testPluginFolder->delete();
$testPluginConfigFolder = new Folder(ROOT . DS . 'config' . DS . 'Plugins' . DS . 'PluginInstallerTest');
$testPluginConfigFolder->delete();
}
示例4: tearDown
/**
* tearDown
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
unset($this->Model);
TableRegistry::clear();
$folder = new Folder(WWW_ROOT . 'upload');
$folder->delete(WWW_ROOT . 'upload');
}
示例5: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
unset($this->Task);
$Folder = new Folder($this->path);
$Folder->delete();
Plugin::unload();
}
示例6: removeAndCreateFolder
private function removeAndCreateFolder($path)
{
$dir = new Folder($path);
$dir->delete();
$dir->create($path);
$file = new File($path . DS . 'empty');
$file->create();
}
示例7: testExistTheme
/**
* Test exist theme plugin.
*
* @return void
*/
public function testExistTheme()
{
$name = Configure::read('Theme.site');
$path = $this->_paths[1] . $name;
$this->_folder->create($path);
$this->assertSame($path, Theme::exist($name));
$this->_folder->delete($path);
}
示例8: createFileAndDeleteTmp
private function createFileAndDeleteTmp($identifier, $filename)
{
$tmpFolder = new Folder($this->tmpChunkDir($identifier));
$chunkFiles = $tmpFolder->read(true, true, true)[1];
if ($this->createFileFromChunks($chunkFiles, $this->uploadFolder . DIRECTORY_SEPARATOR . $filename) && $this->deleteTmpFolder) {
$tmpFolder->delete();
}
}
示例9: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
$this->File->close();
unset($this->File);
$Folder = new Folder();
$Folder->delete(TMP . 'tests/permissions');
}
示例10: tearDown
public function tearDown()
{
parent::tearDown();
Plugin::unload('ThemeInstallerTest');
$testPluginFolder = new Folder(ROOT . DS . 'plugins' . DS . 'ThemeInstallerTest');
$testPluginFolder->delete();
$testPluginConfigFolder = new Folder(ROOT . DS . 'config' . DS . 'Plugins' . DS . 'ThemeInstallerTest');
$testPluginConfigFolder->delete();
$webrootThemeFolder = new Folder(WWW_ROOT . 'theme' . DS . 'ThemeInstallerTest');
$webrootThemeFolder->delete();
}
示例11: testAddTestDirectoryRecursiveWithNonPhp
/**
* testAddTestDirectoryRecursiveWithNonPhp
*
* @return void
*/
public function testAddTestDirectoryRecursiveWithNonPhp()
{
$this->skipIf(!is_writable(TMP), 'Cant addTestDirectoryRecursiveWithNonPhp unless the tmp folder is writable.');
$Folder = new Folder(TMP . 'MyTestFolder', true, 0777);
touch($Folder->path . DS . 'BackupTest.php~');
touch($Folder->path . DS . 'SomeNotesTest.txt');
touch($Folder->path . DS . 'NotHiddenTest.php');
$suite = $this->getMock('Cake\\TestSuite\\TestSuite', ['addTestFile']);
$suite->expects($this->exactly(1))->method('addTestFile');
$suite->addTestDirectoryRecursive($Folder->pwd());
$Folder->delete();
}
示例12: deleteFolder
/**
* Delete folder action.
*
* @return \Cake\Network\Response|void
*/
public function deleteFolder()
{
$path = $this->request->query('path');
if ($this->request->is('post') && is_dir($path)) {
$Folder = new Folder($path);
if ($Folder->delete()) {
$this->Flash->success(__d('file_manager', 'Folder successfully removed'));
} else {
$this->Flash->success(__d('file_manager', 'An error occurred while removing a folder'));
}
}
return $this->redirect(['action' => 'browse']);
}
示例13: afterDelete
/**
* afterDelete
*
* No need to use an adapter here, just delete the whole folder using cakes Folder class
*
* @param Event $event
* @return boolean|null
*/
public function afterDelete(Event $event)
{
if ($this->_checkEvent($event)) {
$entity = $event->data['record'];
$storageConfig = StorageManager::config($entity['adapter']);
$path = $storageConfig['adapterOptions'][0] . $event->data['record']['path'];
if (is_dir($path)) {
$Folder = new Folder($path);
$Folder->delete();
$event->stopPropagation();
$event->result = true;
return true;
}
$event->stopPropagation();
$event->result = false;
return false;
}
}
示例14: handleChunk
public function handleChunk()
{
$file = $this->request->file();
$identifier = $this->_resumableParam('identifier');
$filename = $this->_resumableParam('filename');
$chunkNumber = $this->_resumableParam('chunkNumber');
$chunkSize = $this->_resumableParam('chunkSize');
$totalSize = $this->_resumableParam('totalSize');
if (!$this->isChunkUploaded($identifier, $filename, $chunkNumber)) {
$chunkFile = $this->tmpChunkDir($identifier) . DIRECTORY_SEPARATOR . $this->tmpChunkFilename($filename, $chunkNumber);
$this->moveUploadedFile($file['tmp_name'], $chunkFile);
}
if ($this->isFileUploadComplete($filename, $identifier, $chunkSize, $totalSize)) {
$tmpFolder = new Folder($this->tmpChunkDir($identifier));
$chunkFiles = $tmpFolder->read(true, true, true)[1];
$this->createFileFromChunks($chunkFiles, $this->uploadFolder . DIRECTORY_SEPARATOR . $filename);
if ($this->deleteTmpFolder) {
$tmpFolder->delete();
}
}
return $this->response->header(200);
}
示例15: main
/**
* main method
*
* @param string $tempDir an other directory to clear of all folders and files, if desired
* @return void
*/
public function main($tempDir = null)
{
if (empty($tempDir)) {
$tempDir = Configure::read('Attachments.tmpUploadsPath');
}
if (!Folder::isAbsolute($tempDir)) {
$this->out('The path must be absolute, "' . $tempDir . '" given.');
exit;
}
$Folder = new Folder();
if ($Folder->cd($tempDir) === false) {
$this->out('Path "' . $tempDir . '" doesn\'t seem to exist.');
exit;
}
$dir = new Folder($tempDir);
$folders = $dir->read();
$files = $dir->findRecursive();
$deletedFiles = 0;
$deletedFolders = 0;
$this->out('Found ' . count($folders[0]) . ' folders and ' . count($files) . ' files');
foreach ($files as $filePath) {
$file = new File($filePath);
// only delete if last change is longer than 24 hours ago
if ($file->lastChange() < time() - 24 * 60 * 60 && $file->delete()) {
$deletedFiles++;
}
$file->close();
}
foreach ($folders[0] as $folderName) {
$folder = new Folder($dir->pwd() . $folderName);
// only delete if folder is empty
if ($folder->dirsize() === 0 && $folder->delete()) {
$deletedFolders++;
}
}
$this->out('Deleted ' . $deletedFolders . ' folders and ' . $deletedFiles . ' files.');
}