FolderHelper.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /** @package verysimple::IO */
  3. /** import supporting libraries */
  4. require_once("FileHelper.php");
  5. /**
  6. * Provided object oriented access to a file system directory
  7. *
  8. * @package verysimple::IO
  9. * @author Jason Hinkle
  10. * @copyright 1997-2007 VerySimple, Inc.
  11. * @license http://www.gnu.org/licenses/lgpl.html LGPL
  12. * @version 1.0
  13. */
  14. class FolderHelper
  15. {
  16. private $Path;
  17. /**
  18. * Constructor
  19. *
  20. * @access public
  21. * @param string $path uri to directory to manipulate
  22. */
  23. function __construct($path)
  24. {
  25. $this->Path = $path;
  26. }
  27. /**
  28. * Returns an array of FileHelper objects
  29. *
  30. * @access public
  31. * @param string $pattern (not yet implemented)
  32. * @return array
  33. */
  34. public function GetFiles($pattern = "")
  35. {
  36. $files = Array();
  37. $dh = opendir($this->Path);
  38. while ($fname = readdir($dh))
  39. {
  40. if (is_file($this->Path.$fname))
  41. {
  42. if ($pattern == "" || preg_match($pattern,$fname) > 0)
  43. {
  44. $files[] = new FileHelper($this->Path.$fname);
  45. }
  46. }
  47. }
  48. closedir($dh);
  49. return $files;
  50. }
  51. }
  52. ?>