public function fileInfo(string $dir, string $extension = NULL) : array { $dir = File::rpath($dir); if (is_dir($dir)) { $files = Factory::class('FileList')->files($dir, $extension); $dir = suffix($dir); $filesInfo = []; foreach ($files as $file) { $filesInfo[$file]['basename'] = pathInfos($dir . $file, 'basename'); $filesInfo[$file]['size'] = filesize($dir . $file); $filesInfo[$file]['date'] = filemtime($dir . $file); $filesInfo[$file]['readable'] = is_readable($dir . $file); $filesInfo[$file]['writable'] = is_writable($dir . $file); $filesInfo[$file]['executable'] = is_executable($dir . $file); $filesInfo[$file]['permission'] = fileperms($dir . $file); } return $filesInfo; } elseif (is_file($dir)) { return (array) File::info($dir); } else { throw new FolderNotFoundException($dir); } }
function extension($file = '', $dote = false) { if (!is_string($file)) { return false; } if (!is_bool($dote)) { $dote = false; } $dote = $dote === true ? '.' : ''; return $dote . strtolower(pathInfos($file, "extension")); }
public function fileInfo($dir = '', $extension = '') { // Parametre kontrolleri yapılıyor. ------------------------------------------- if (!is_string($dir)) { return Error::set(lang('Error', 'stringParameter', 'dir')); } if (!is_string($extension)) { $extension = ''; } // ---------------------------------------------------------------------------- if (is_dir($dir)) { $files = $this->files($dir, $extension); $dir = suffix($dir); $filesInfo = array(); foreach ($files as $file) { $filesInfo[$file]['basename'] = pathInfos($dir . $file, 'basename'); $filesInfo[$file]['size'] = filesize($dir . $file); $filesInfo[$file]['date'] = filemtime($dir . $file); $filesInfo[$file]['readable'] = is_readable($dir . $file); $filesInfo[$file]['writable'] = is_writable($dir . $file); $filesInfo[$file]['executable'] = is_executable($dir . $file); $filesInfo[$file]['permission'] = fileperms($dir . $file); } return $filesInfo; } elseif (is_file($dir)) { $fileinfo = File::info($dir); return (array) $fileinfo; } else { return Error::set(lang('Error', 'fileDirParameter', 'dir')); } }
public function info($file = '') { if (!is_file($file)) { return Error::set('Error', 'fileParameter', 'file'); } return (object) array('basename' => pathInfos($file, 'basename'), 'size' => filesize($file), 'date' => filemtime($file), 'readable' => is_readable($file), 'writable' => is_writable($file), 'executable' => is_executable($file), 'permission' => fileperms($file)); }
public function createZip(string $path, array $data) : bool { $path = File::rpath($path); $zip = new ZipArchive(); $zipPath = suffix($path, ".zip"); if (file_exists($zipPath)) { unlink($zipPath); } if (!is_dir($pathDirName = pathInfos($path, 'dirname'))) { Folder::create($pathDirName); } if ($zip->open($zipPath, ZipArchive::CREATE) !== true) { return false; } $status = ''; if (!empty($data)) { foreach ($data as $key => $val) { if (is_numeric($key)) { $file = $val; $fileName = NULL; } else { $file = $key; $fileName = $val; } if (is_dir($file)) { $allFiles = Folder::allFiles($file, true); foreach ($allFiles as $f) { $status = $zip->addFile($f, $f); } } else { $status = $zip->addFile($file, $fileName); } } } return $zip->close(); }
public function get(string $file) : \stdClass { $file = $this->rpath($file); if (!is_file($file)) { throw new FileNotFoundException($file); } return (object) ['basename' => pathInfos($file, 'basename'), 'size' => filesize($file), 'date' => filemtime($file), 'readable' => is_readable($file), 'writable' => is_writable($file), 'executable' => is_executable($file), 'permission' => fileperms($file)]; }
function extension(string $file, bool $dote = false) : string { $dote = $dote === true ? '.' : ''; return $dote . strtolower(pathInfos($file, "extension")); }