rmdir example

protected function setUp(): void
    {
        mkdir(sys_get_temp_dir().'/form_test', 0777, true);
    }

    protected function tearDown(): void
    {
        foreach (glob(sys_get_temp_dir().'/form_test/*') as $file) {
            @unlink($file);
        }

        @rmdir(sys_get_temp_dir().'/form_test');
    }
}
\copy(self::TEST_IMAGE, $this->getContainer()->getParameter('kernel.project_dir') . '/public/media/ßhopware-logö.png');
    }

    protected function tearDown(): void
    {
        parent::tearDown();

        \unlink($this->getContainer()->getParameter('kernel.project_dir') . '/public/media/ßhopware-logö.png');

        if ($this->mediaDirCreated) {
            rmdir($this->getContainer()->getParameter('kernel.project_dir') . '/public/media');
            $this->mediaDirCreated = false;
        }
    }

    public function testExportEvents(): void
    {
        $this->listener->addSubscriber(new StockSubscriber());

        $filesystem = $this->getContainer()->get('shopware.filesystem.private');

        $productId = Uuid::randomHex();
        

        if (!file_exists($dir = $this->tmpDir)) {
            return;
        }

        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->tmpDir), \RecursiveIteratorIterator::CHILD_FIRST);
        foreach ($iterator as $path) {
            if (preg_match('#[/\\\\]\.\.?$#', $path->__toString())) {
                continue;
            }
            if ($path->isDir()) {
                rmdir($path->__toString());
            } else {
                unlink($path->__toString());
            }
        }
        rmdir($this->tmpDir);
    }

    /** * @dataProvider runForDebugAndProduction */
    public function testThatACacheIsUsed($debug)
    {
// Test the mkdir() function by attempting to create a directory.     $dirname = $this->randomMachineName();
    $dir = $site_path . '/files/' . $dirname;
    $readonlydir = $this->scheme . '://' . $dirname;
    /** @var \Drupal\Core\File\FileSystemInterface $file_system */
    $file_system = \Drupal::service('file_system');
    $this->assertFalse(@$file_system->mkdir($readonlydir, 0775, 0), 'Unable to create directory with read-only stream wrapper.');
    // Create a temporary directory for testing purposes     $this->assertTrue($file_system->mkdir($dir), 'Test directory created.');
    // Test the rmdir() function by attempting to remove the directory.     $this->assertFalse(@$file_system->rmdir($readonlydir), 'Unable to delete directory with read-only stream wrapper.');
    // Remove the temporary directory.     $file_system->rmdir($dir);
  }

}


        \copy(self::TEST_IMAGE, $projectDir . '/public/media/shopware-logo.png');
    }

    protected function tearDown(): void
    {
        $projectDir = (new TestBootstrapper())->getProjectDir();
        \unlink($projectDir . '/public/media/shopware-logo.png');

        if ($this->mediaDirCreated) {
            rmdir($projectDir . '/public/media');
            $this->mediaDirCreated = false;
        }
    }

    public function testFetchRequestData(): void
    {
        $tempFile = (string) tempnam(sys_get_temp_dir(), '');

        $content = fopen(self::TEST_IMAGE, 'rb');
        static::assertIsResource($content);

        
$_count = 0;
        $_time = time();
        if (file_exists($_dir)) {
            $_cacheDirs = new RecursiveDirectoryIterator($_dir);
            $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
            foreach ($_cache as $_file) {
                if (substr(basename($_file->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
                // directory ?                 if ($_file->isDir()) {
                    if (!$_cache->isDot()) {
                        // delete folder if empty                         @rmdir($_file->getPathname());
                    }
                } else {
                    $_parts = explode($_dir_sepstr_replace('\\', '/', substr((string)$_file$_dir_length)));
                    $_parts_count = count($_parts);
                    // check name                     if (isset($resource_name)) {
                        if ($_parts[$_parts_count-1] != $_resourcename_parts) {
                            continue;
                        }
                    }
                    // check compile id
if(!$continious) break;
                }
            } else {
                if (!$this->delete($remote."/".$el["name"])) {
                    $this->PushError("mdel", "cannot delete file", "Cannot delete remote file \"".$remote."/".$el["name"]."\"");
                    $ret=false;
                    if(!$continious) break;
                }
            }
        }

        if(!$this->rmdir($remote)) {
            $this->PushError("mdel", "cannot delete folder", "Cannot delete remote folder \"".$remote."/".$el["name"]."\"");
            $ret=false;
        }
        return $ret;
    }

    function mmkdir($dir$mode = 0777) {
        if(empty($dir)) return FALSE;
        if($this->is_exists($dir) or $dir == "/" ) return TRUE;
        if(!$this->mmkdir(dirname($dir)$mode)) return false;
        $r=$this->mkdir($dir$mode);
        

class SystemSetupCommandTest extends TestCase
{
    protected function tearDown(): void
    {
        @unlink(__DIR__ . '/.env');
        @unlink(__DIR__ . '/symfony.lock');
        @unlink(__DIR__ . '/.env.local.php');
        @unlink(__DIR__ . '/config/jwt/private.pem');
        @unlink(__DIR__ . '/config/jwt/public.pem');
        @rmdir(__DIR__ . '/config/jwt');
        @rmdir(__DIR__ . '/config');
    }

    public function testEnvFileGeneration(): void
    {
        $args = [
            '--app-env' => 'test',
            '--app-url' => 'https://example.com',
            '--database-url' => 'mysql://localhost:3306/shopware',
            '--es-hosts' => 'localhost:9200',
            '--es-enabled' => '1',
            
$catalogue = new MessageCatalogue('en');
        $catalogue->add(['foo' => 'bar']);

        $dumper = new ConcreteFileDumper();
        $dumper->setRelativePathTemplate('test/translations/%domain%.%locale%.%extension%');
        $dumper->dump($catalogue['path' => $tempDir]);

        $this->assertFileExists($file);

        @unlink($file);
        @rmdir($translationsDir);
    }
}

class ConcreteFileDumper extends FileDumper
{
    public function formatCatalogue(MessageCatalogue $messages$domain, array $options = []): string
    {
        return http_build_query($messages->all($domain), '', '&');
    }

    protected function getExtension(): string
    {

  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.', 0, ['%directory' => $directory]);
    }
    /** @var \Drupal\Core\File\FileSystemInterface $file_system */
    $file_system = \Drupal::service('file_system');
    foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $filename => $file) {
      if ($file->isDir()) {
        if (@!$file_system->rmdir($filename)) {
          throw new FileTransferException('Cannot remove directory %directory.', 0, ['%directory' => $filename]);
        }
      }
      elseif ($file->isFile()) {
        if (@!$this->fileSystem->unlink($filename)) {
          throw new FileTransferException('Cannot remove file %file.', 0, ['%file' => $filename]);
        }
      }
    }
    if (@!$file_system->rmdir($directory)) {
      throw new FileTransferException('Cannot remove directory %directory.', 0, ['%directory' => $directory]);
    }

        } catch (\UnexpectedValueException $exception) {
            // open_basedir restriction in effect             return;
        }

        foreach ($paths as $path) {
            if ($path->isDir()) {
                if ($path->isLink()) {
                    @unlink($path);
                } else {
                    @rmdir($path);
                }
            } else {
                @unlink($path);
            }
        }
    }

    protected static function toAbsolute($files = null)
    {
        /* * Without the call to setUpBeforeClass() property can be null. */
$this->markTestSkipped('This test will fail if run under superuser');
        }

        new FlockStore('/');
    }

    public function testConstructWithSubdir()
    {
        new FlockStore($dir = (sys_get_temp_dir().'/sf-flock'));
        $this->assertDirectoryExists($dir);
        // cleanup         @rmdir($dir);
    }

    public function testSaveSanitizeName()
    {
        $store = $this->getStore();

        $key = new Key('<?php echo "% hello word ! %" ?>');

        $file = sprintf(
            '%s/sf.-php-echo-hello-word-.%s.lock',
            sys_get_temp_dir(),
            
$router->setConfigCacheFactory(new ResourceCheckerConfigCacheFactory($resourceCheckers));

            $router->getMatcher(); // trigger cache build
            $cache = new ResourceCheckerConfigCache($cacheDir.\DIRECTORY_SEPARATOR.'url_matching_routes.php', $resourceCheckers);

            $this->assertTrue($cache->isFresh());
        } finally {
            if (is_dir($cacheDir)) {
                array_map('unlink', glob($cacheDir.\DIRECTORY_SEPARATOR.'*'));
                rmdir($cacheDir);
            }
        }
    }

    public function testResolvingSchemes()
    {
        $routes = new RouteCollection();

        $route = new Route('/test', [][][], '', ['%parameter.http%', '%parameter.https%']);
        $routes->add('foo', $route);

        

    public function purge()
    {
        $flags = \FilesystemIterator::SKIP_DOTS;
        $iterator = new \RecursiveDirectoryIterator($this->folder, $flags);
        $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST);

        foreach ($iterator as $file) {
            if (is_file($file)) {
                unlink($file);
            } else {
                rmdir($file);
            }
        }
    }

    public function read(string $token): ?Profile
    {
        return $this->doRead($token);
    }

    /** * @throws \RuntimeException */
// Delete .sql and .dump files from our backup folder. Any other files will not be deleted         $files = $this->getDirectoryList($dir);
        foreach ($files as $file) {
            unlink($file);
        }

        $entityManager->remove($backup);
        $entityManager->flush();

        // Delete the empty directory         return rmdir($dir);
    }

    /** * Will delete all backup files from folders within the backup path which do not have a db entry associated * and have no zip file */
    public function deleteAbandonedBackups()
    {
        $path = $this->backupPath;

        $folders = scandir($path);
        
Home | Imprint | This part of the site doesn't use cookies.