Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @category unknown
- * @copyright Copyright (c) 2011, Hidek1 [rhyudek1@gmail.com]
- * @license Atribución-Licenciar Igual 2.0 Chile.
- * @since 29-mar-2011
- * @version 1 (29-mar-2011)
- */
- class FileFunctions
- {
- private $_files = array();
- private $_folders = array();
- public function __construct($route)
- {
- if (is_dir($route)) {
- $route = realpath($route) . DIRECTORY_SEPARATOR;
- $directory = opendir($route);
- while (false !== ($element = readdir($directory))) {
- switch (true) {
- case is_file($route . $element):
- $this->_files[] = $element;
- break;
- case $element != '.' && $element != '..':
- $this->_folders[] = $element;
- break;
- }
- }
- closedir($directory);
- }
- }
- public function getFolders()
- {
- return $this->_folders;
- }
- public function getFiles()
- {
- return $this->_files;
- }
- public function getFileType($extension)
- {
- $return_files = array();
- foreach ($this->_files as $file) {
- $ext = pathinfo($file, PATHINFO_EXTENSION);
- if ($ext == $extension) {
- $return_files[] = $file;
- }
- }
- return $return_files;
- }
- }
Add Comment
Please, Sign In to add comment