Assert that a directory exists and is not empty.

@param mixed  $filename
@param string $message
553940
public static function assertDirectoryNotEmpty($filename, string $message = '')
    {
        self::assertThatConstraint($filename, $message, 'assertDirectoryNotEmpty', new LogicalNot(new DirectoryEmptyConstraint()));
    }
111912
public function exist(string $filename): ExistCommand
    {
        /** @var ExistCommand $command */
        $command = $this->builder->build(ExistCommand::class);
        $command->byFilename($filename);

        return $command;
    }
1301193
public function appendMessage($message, $folder = null, $flags = null, $recent = false)
    {
        if ($this->_quota && $this->checkQuota()) {
            /**
             * @see Zend_Mail_Storage_Exception
             */
            // require_once 'Zend/Mail/Storage/Exception.php';
            throw new Zend_Mail_Storage_Exception('storage is over quota!');
        }

        if ($folder === null) {
            $folder = $this->_currentFolder;
        }

        if (!($folder instanceof Zend_Mail_Storage_Folder)) {
            $folder = $this->getFolders($folder);
        }

        if ($flags === null) {
            $flags = array(Zend_Mail_Storage::FLAG_SEEN);
        }
        $info = $this->_getInfoString($flags);
        $temp_file = $this->_createTmpFile($folder->getGlobalName());

        // TODO: handle class instances for $message
        if (is_resource($message) && get_resource_type($message) == 'stream') {
            stream_copy_to_stream($message, $temp_file['handle']);
        } else {
            fputs($temp_file['handle'], $message);
        }
        fclose($temp_file['handle']);

        // we're adding the size to the filename for maildir++
        $size = filesize($temp_file['filename']);
        if ($size !== false) {
            $info = ',S=' . $size . $info;
        }
        $new_filename = $temp_file['dirname'] . DIRECTORY_SEPARATOR;
        $new_filename .= $recent ? 'new' : 'cur';
        $new_filename .= DIRECTORY_SEPARATOR . $temp_file['uniq'] . $info;

        // we're throwing any exception after removing our temp file and saving it to this variable instead
        $exception = null;

        if (!link($temp_file['filename'], $new_filename)) {
            /**
             * @see Zend_Mail_Storage_Exception
             */
            // require_once 'Zend/Mail/Storage/Exception.php';
            $exception = new Zend_Mail_Storage_Exception('cannot link message file to final dir');
        }
        @unlink($temp_file['filename']);

        if ($exception) {
            throw $exception;
        }

        $this->_files[] = array('uniq'     => $temp_file['uniq'],
                                'flags'    => $flags,
                                'filename' => $new_filename);
        if ($this->_quota) {
            $this->_addQuotaEntry((int)$size, 1);
        }
    }
453569
public function setFilename($filename , $directory = null)
    {
        $this->filename  = $filename;
        $this->directory = $directory;
    }
123145
public function hasFile($filename)
    {
        return is_file($filename = $this->outDir.DIRECTORY_SEPARATOR.$filename) ? true : false;
    }
71366
protected function success($message)
    {
        if ($this->isVerbose() === true) {
            $this->out("%g${message}%n", true);
        }
        
        exit(self::EXIT_SUCCESS);
    }
1224941
public function fileExists($filename)
    {
        return isset($this->_fileHandlers[$filename]) ||
               file_exists($this->_dirPath . '/' . $filename);
    }
1157139
protected function log($message)
    {

        if ($this->debug == true) {
            file_put_contents("php://stdout", $message . "\n");
        }

        file_put_contents($this->dump_dir . 'dump.log', $message . "\n", \FILE_APPEND);
    }
1080415
public function hasExceptionOfMessage($message)
    {
        foreach ($this->_exceptions as $e) {
            if ($message == $e->getMessage()) {
                return true;
            }
        }

        return false;
    }
458280
public function fileExists($containerName, $fileName, $relativePath)
    {
        return $this->fileUploadFacade->fileExists($containerName, $fileName, $relativePath);
    }
365654
public function log($message)
    {
        if ($this->enabled) {
            $entry = $this->formatMessage($message);
            $fp = fopen($this->file, "a");
            fwrite($fp, $entry . PHP_EOL);
            fclose($fp);
        }
    }
1024629
public function assertIsStringAndNonEmpty($value, $message='%s must be a string and not empty', $exception='Asserts')
    {
        if (is_string($value) === false || strlen($value) < 1) {
            $this->throwException($exception, $message, $value);
        }
    }
1226970
private function findFileInPath($filename, $path)
    {
        $path = $this->absolutizePath($path);
        if (!file_exists($path)) {
            $this->fail("Directory does not exist: $path");
        }

        $files = Finder::create()->files()->name($filename)->in($path);
        if ($files->count() === 0) {
            return false;
        }

        foreach ($files as $file) {
            return $file->getRealPath();
        }
    }
925395
private function fileReader($filename)
    {
        //Check if the path is defined
        if(empty($this->message_path))
        {
            $this->message_path = __DIR__.DIRECTORY_SEPARATOR.'messages'.DIRECTORY_SEPARATOR;
        }

        //Read message file and return content
        $message = file_get_contents($this->message_path.$filename.'.livia');
        //Return the message
        return $message;
    }
1070463
final protected function assertClassSatisfiesSpecification(callable $specification, string $className, string $message = ''): void
    {
        $this->assertClassExists($className);

        self::assertTrue($specification($className), \sprintf(
            '' !== $message ? $message : 'Failed asserting that class "%s" satisfies a specification.',
            $className
        ));
    }
138476
private function createFileDirIfNotExists(string $filename): bool
    {
        $pathinfo = pathinfo($filename);
        if (isset($pathinfo['dirname']) && $pathinfo['dirname'] !== '.') {
            if (is_dir($pathinfo['dirname'])) {
                return true;
            } elseif (is_file($pathinfo['dirname'])) {
                return false;
            } else {
                return $this->createDirIfNotExists($pathinfo['dirname']);
            }
        }
        return false;
    }
922747
public function checkFileSize($fileName, $fileSize)
    {
        $this->inCurrentDir(function() use ($fileName, $fileSize) {
            if (filesize($fileName) !== $fileSize) {
                throw new ExpectationException("Size of $fileName not equals $fileSize");
            }
        });
    }