FileHelper.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /** @package verysimple::IO */
  3. /**
  4. * Provides helper functions for dealing with a file
  5. *
  6. * @package verysimple::IO
  7. * @author Jason Hinkle
  8. * @copyright 1997-2007 VerySimple, Inc.
  9. * @license http://www.gnu.org/licenses/lgpl.html LGPL
  10. * @version 1.0
  11. */
  12. class FileHelper
  13. {
  14. public $Name;
  15. public $Path;
  16. public $FolderPath;
  17. public $Extention;
  18. public $Prefix;
  19. public $MiddleBit;
  20. /**
  21. * Creates a new instance of a FileHelper object
  22. *
  23. * @access public
  24. * @param $path The full path to the file
  25. */
  26. function __construct($path)
  27. {
  28. //TODO: user build-in php functions to extract these properties
  29. $this->Path = str_replace("\\","/", $path); // normalize any directory paths
  30. $this->Name = substr($this->Path, strrpos($this->Path,"/")+1);
  31. $this->Extention = substr($this->Path, strrpos($this->Path,".")+1);
  32. $this->Prefix = substr($this->Name, 0, strpos($this->Name,"."));
  33. $this->MiddleBit = substr($this->Name, strpos($this->Name,".")+1, strrpos($this->Name,".")-strpos($this->Name,".")-1);
  34. $this->FolderPath = substr($this->Path, 0, strrpos($this->Path,"/")+1);
  35. }
  36. }
  37. ?>