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


PHP drupal_rmdir函数代码示例

本文整理汇总了PHP中drupal_rmdir函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_rmdir函数的具体用法?PHP drupal_rmdir怎么用?PHP drupal_rmdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testReadOnlyBehavior

 /**
  * Test read-only specific behavior.
  */
 function testReadOnlyBehavior()
 {
     // Generate a test file
     $filename = $this->randomMachineName();
     $site_path = $this->container->get('site.path');
     $filepath = $site_path . '/files/' . $filename;
     file_put_contents($filepath, $filename);
     // Generate a read-only stream wrapper instance
     $uri = $this->scheme . '://' . $filename;
     file_stream_wrapper_get_instance_by_scheme($this->scheme);
     // Attempt to open a file in read/write mode
     $handle = @fopen($uri, 'r+');
     $this->assertFalse($handle, 'Unable to open a file for reading and writing with the read-only stream wrapper.');
     // Attempt to open a file in binary read mode
     $handle = fopen($uri, 'rb');
     $this->assertTrue($handle, 'Able to open a file for reading in binary mode with the read-only stream wrapper.');
     $this->assertTrue(fclose($handle), 'Able to close file opened in binary mode using the read_only stream wrapper.');
     // Attempt to open a file in text read mode
     $handle = fopen($uri, 'rt');
     $this->assertTrue($handle, 'Able to open a file for reading in text mode with the read-only stream wrapper.');
     $this->assertTrue(fclose($handle), 'Able to close file opened in text mode using the read_only stream wrapper.');
     // Attempt to open a file in read mode
     $handle = fopen($uri, 'r');
     $this->assertTrue($handle, 'Able to open a file for reading with the read-only stream wrapper.');
     // Attempt to change file permissions
     $this->assertFalse(@chmod($uri, 0777), 'Unable to change file permissions when using read-only stream wrapper.');
     // Attempt to acquire an exclusive lock for writing
     $this->assertFalse(@flock($handle, LOCK_EX | LOCK_NB), 'Unable to acquire an exclusive lock using the read-only stream wrapper.');
     // Attempt to obtain a shared lock
     $this->assertTrue(flock($handle, LOCK_SH | LOCK_NB), 'Able to acquire a shared lock using the read-only stream wrapper.');
     // Attempt to release a shared lock
     $this->assertTrue(flock($handle, LOCK_UN | LOCK_NB), 'Able to release a shared lock using the read-only stream wrapper.');
     // Attempt to truncate the file
     $this->assertFalse(@ftruncate($handle, 0), 'Unable to truncate using the read-only stream wrapper.');
     // Attempt to write to the file
     $this->assertFalse(@fwrite($handle, $this->randomMachineName()), 'Unable to write to file using the read-only stream wrapper.');
     // Attempt to flush output to the file
     $this->assertFalse(@fflush($handle), 'Unable to flush output to file using the read-only stream wrapper.');
     // Attempt to close the stream.  (Suppress errors, as fclose triggers fflush.)
     $this->assertTrue(fclose($handle), 'Able to close file using the read_only stream wrapper.');
     // Test the rename() function
     $this->assertFalse(@rename($uri, $this->scheme . '://newname.txt'), 'Unable to rename files using the read-only stream wrapper.');
     // Test the unlink() function
     $this->assertTrue(@drupal_unlink($uri), 'Able to unlink file using read-only stream wrapper.');
     $this->assertTrue(file_exists($filepath), 'Unlink File was not actually deleted.');
     // Test the mkdir() function by attempting to create a directory.
     $dirname = $this->randomMachineName();
     $dir = $site_path . '/files/' . $dirname;
     $readonlydir = $this->scheme . '://' . $dirname;
     $this->assertFalse(@drupal_mkdir($readonlydir, 0775, 0), 'Unable to create directory with read-only stream wrapper.');
     // Create a temporary directory for testing purposes
     $this->assertTrue(drupal_mkdir($dir), 'Test directory created.');
     // Test the rmdir() function by attempting to remove the directory.
     $this->assertFalse(@drupal_rmdir($readonlydir), 'Unable to delete directory with read-only stream wrapper.');
     // Remove the temporary directory.
     drupal_rmdir($dir);
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:60,代码来源:ReadOnlyStreamWrapperTest.php

示例2: removeDirectoryJailed

 /**
  * Implements Drupal\Core\FileTransfer\FileTransfer::removeDirectoryJailed().
  */
 protected function removeDirectoryJailed($directory)
 {
     if (!is_dir($directory)) {
         // Programmer error assertion, not something we expect users to see.
         throw new FileTransferException('removeDirectoryJailed() called with a path (%directory) that is not a directory.', NULL, array('%directory' => $directory));
     }
     foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $filename => $file) {
         if ($file->isDir()) {
             if (@(!drupal_rmdir($filename))) {
                 throw new FileTransferException('Cannot remove directory %directory.', NULL, array('%directory' => $filename));
             }
         } elseif ($file->isFile()) {
             if (@(!drupal_unlink($filename))) {
                 throw new FileTransferException('Cannot remove file %file.', NULL, array('%file' => $filename));
             }
         }
     }
     if (@(!drupal_rmdir($directory))) {
         throw new FileTransferException('Cannot remove directory %directory.', NULL, array('%directory' => $directory));
     }
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:24,代码来源:Local.php

示例3: deleteAll

 /**
  * {@inheritdoc}
  */
 public function deleteAll($prefix = '')
 {
     $success = TRUE;
     $files = $this->listAll($prefix);
     foreach ($files as $name) {
         if (!$this->delete($name) && $success) {
             $success = FALSE;
         }
     }
     if ($success && $this->collection != StorageInterface::DEFAULT_COLLECTION) {
         // Remove empty directories.
         if (!(new \FilesystemIterator($this->getCollectionDirectory()))->valid()) {
             drupal_rmdir($this->getCollectionDirectory());
         }
     }
     return $success;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:20,代码来源:FileStorage.php

示例4: rmdir

 /**
  * Support for rmdir().
  *
  * @param string $uri
  *   A string containing the URI to the directory to delete.
  * @param int $options
  *   A bit mask of STREAM_REPORT_ERRORS.
  *
  * @return bool
  *   TRUE if directory was successfully removed.
  *
  * @see http://php.net/manual/streamwrapper.rmdir.php
  */
 public function rmdir($uri, $options)
 {
     $this->uri = $uri;
     if ($options & STREAM_REPORT_ERRORS) {
         return drupal_rmdir($this->getLocalPath());
     } else {
         return @drupal_rmdir($this->getLocalPath());
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:22,代码来源:LocalStream.php

示例5: deleteFolder

 public function deleteFolder($filedepot_folder_id)
 {
     /* Test for valid folder and admin permission one more time
      * We are going to override the permission test in the function filedepot_getRecursiveCatIDs()
      * and return all subfolders in case hidden folders exist for this user.
      * If this user has admin permission for parent -- then they should be able to delete it
      * and any subfolders.
      */
     if ($filedepot_folder_id > 0 and $this->checkPermission($filedepot_folder_id, 'admin')) {
         // Need to delete all files in the folder
         /* Build an array of all linked categories under this category the user has admin access to */
         $list = array();
         array_push($list, $filedepot_folder_id);
         // Passing in permission check over-ride as noted above to filedepot_getRecursiveCatIDs()
         $list = $this->getRecursiveCatIDs($list, $filedepot_folder_id, 'admin', TRUE);
         foreach ($list as $cid) {
             // Drupal will remove the file attachments automatically when folder node is deleted even if file usage is > 1
             $query = db_query("SELECT drupal_fid FROM {filedepot_files} WHERE cid=:cid", array(':cid' => $cid));
             while ($A = $query->fetchAssoc()) {
                 $file = file_load($A['drupal_fid']);
                 file_usage_delete($file, 'filedepot');
                 if (file_exists($file->uri)) {
                     file_delete($file);
                 }
             }
             $subfolder_nid = db_query("SELECT nid FROM {filedepot_categories} WHERE cid=:cid", array(':cid' => $cid))->fetchField();
             db_delete('filedepot_categories')->condition('cid', $cid)->execute();
             db_delete('filedepot_categories')->condition('cid', $cid)->execute();
             db_delete('filedepot_access')->condition('catid', $cid)->execute();
             db_delete('filedepot_recentfolders')->condition('cid', $cid)->execute();
             db_delete('filedepot_notifications')->condition('cid', $cid)->execute();
             db_delete('filedepot_filesubmissions')->condition('cid', $cid)->execute();
             // Call the drupal node delete now for the subfolder node
             //watchdog('filedepot',"Calling node_delete for node id: {$subfolder_nid}");
             node_delete($subfolder_nid);
             // Remove the physical directory
             $uri = $this->root_storage_path . $cid;
             if (file_exists($uri)) {
                 $ret = @unlink("{$uri}/.htaccess");
                 $ret = @unlink("{$uri}/submissions/.htaccess");
                 $ret = @drupal_rmdir("{$uri}/submissions");
                 $ret = @drupal_rmdir($uri);
             }
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:dalia-m-elsayed,项目名称:spica,代码行数:49,代码来源:filedepot.class.php

示例6: cleanup

 /**
  * Cleanup files created during download().
  *
  * It is expected that $files is returned from download(). Also, be aware that
  * each parent directory in the hierarchy may be removed if there are no more
  * files left in that directory.
  *
  * @param [] $files
  *   Array of files as returned from download() method.
  */
 public static function cleanup(array $files)
 {
     foreach ($files as $file_path => $file_name) {
         // Handle managed files.
         if (count(file_load_multiple([], ['uri' => $file_path])) > 0) {
             $file_obj = new \stdClass();
             $file_obj->uri = $file_path;
             file_delete($file_obj);
         } else {
             file_unmanaged_delete($file_path);
         }
         // Remove all directories in the tree if the file was the last one in this
         // directory.
         $file_dir = dirname($file_path);
         while (count(file_scan_directory($file_dir, '/.*/')) === 0) {
             if (!is_dir($file_dir)) {
                 break;
             }
             drupal_rmdir($file_dir);
             $file_dir = dirname($file_dir);
         }
     }
 }
开发者ID:alexdesignworks,项目名称:drupal_file_downloader,代码行数:33,代码来源:Downloader.php

示例7: drupal_get_path

<?php

/**
 * @file
 * Adminimal Menu Update file 7100.
 */
// Define Adminimal Menu path.
$module_path = drupal_get_path('module', 'adminimal_admin_menu');
// Delete the "adminimal_admin_menu.js" file.
file_unmanaged_delete($module_path . '/adminimal_admin_menu.js');
// Empty the "slicknav" folder.
file_unmanaged_delete_recursive($module_path . '/slicknav');
// Delete the "slicknav" folder.
drupal_rmdir($module_path . '/slicknav');
开发者ID:blashbrook,项目名称:theming,代码行数:14,代码来源:update_7100.php


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