19 declare(strict_types=1);
45 int $next_version_number,
46 int $revision_owner_id,
47 string $revision_title,
48 ?
string $file_name =
null 50 $metadata = $file_stream->getMetadata();
51 $uri = $metadata[
'uri'];
56 $this->file_stream =
new ZIPStream(fopen($uri,
'rb'));
64 $this->suffix = pathinfo((
string) $this->file_name, PATHINFO_EXTENSION);
72 $this->mime_type =
'unknown';
73 if (function_exists(
'mime_content_type') && file_exists($this->path)) {
74 $this->mime_type = mime_content_type($this->path);
78 if (class_exists(
'finfo')) {
79 $finfo = finfo_open(FILEINFO_MIME_TYPE);
81 $this->mime_type = finfo_buffer($finfo, $this->file_stream->read(255));
82 if ($this->file_stream->isSeekable()) {
83 $this->file_stream->rewind();
86 if ($this->mime_type ===
'application/zip' && $this->suffix !==
'zip') {
89 if ($this->mime_type ===
'application/x-empty') {
99 $this->size = $this->file_stream->getSize();
101 $mb_strlen_exists = function_exists(
'mb_strlen');
103 while ($content = $this->file_stream->read(1_048_576)) {
104 if ($mb_strlen_exists) {
105 $this->size += mb_strlen($content,
'8bit');
107 $this->size += strlen($content);
111 if ($this->file_stream->isSeekable()) {
112 $this->file_stream->rewind();
119 $filectime = file_exists($this->path) ? filectime($this->path) :
false;
120 $this->creation_date = $filectime ? (new \DateTimeImmutable())->setTimestamp(
122 ) : new \DateTimeImmutable();
127 if ($file_name !==
null) {
131 $this->file_name = basename($this->path);
133 if ($this->file_name ===
'memory' || $this->file_name ===
'input' || $this->file_name ===
'temp') {
166 $suffix_with_dot =
'.' . $this->
getSuffix();
167 if (array_key_exists($suffix_with_dot, $mime_types_array)) {
168 return $mime_types_array[$suffix_with_dot];
170 return 'application/octet-stream';
__construct(FileStream $file_stream, int $next_version_number, int $revision_owner_id, string $revision_title, ?string $file_name=null)
initFileName(?string $file_name=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
DateTimeImmutable $creation_date
__construct(Container $dic, ilPlugin $plugin)
The base interface for all filesystem streams.