$data['mtime'] = mktime($hour, $minute, $second, $month, $day, $year);
$data += unpack('Vcrc32/VcompressedSize/Vsize/vfilenameLength/vextraFieldLength/vfileCommentLength/vdiskNo/vinternalAttr/vexternalAttr', $this->read(26));
- if ($data['compressedSize'] > 0) $data['type'] = 'file';
- else $data['type'] = 'folder';
$data['offset'] = $this->readAndUnpack(4, 'v');
$data['filename'] = $this->read($data['filenameLength']);
+ if (substr($data['filename'], -1) == '/') $data['type'] = 'folder';
+ else $data['type'] = 'file';
// read extraField
if ($data['extraFieldLength'] > 0) $data['extraField'] = $this->read($data['extraFieldLength']);
// read contents
$header['type'] = 'file';
- if ($header['compressedSize'] > 0) $content = $this->read($header['compressedSize']);
+ if (substr($header['filename'], -1) != '/') $content = $this->read($header['compressedSize']);
else {
$header['type'] = 'folder';
$content = false;
<?php
namespace wcf\system\io;
+use wcf\util\FileUtil;
use wcf\util\StringUtil;
/**
public function addDir($name) {
// replace backward slashes with forward slashes in the dirname
$name = StringUtil::replace("\\", "/", $name);
+ $name = FileUtil::addTrailingSlash($name);
// construct the general header information for the directory
$header = "\x50\x4b\x03\x04";