IOException.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * CFPropertyList
  4. * {@link http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/plist.5.html Property Lists}
  5. * @author Rodney Rehm <[email protected]>
  6. * @author Christian Kruse <[email protected]>
  7. * @package plist
  8. * @version $Id$
  9. */
  10. /**
  11. * Basic Input / Output Exception
  12. * @author Rodney Rehm <[email protected]>
  13. * @author Christian Kruse <[email protected]>
  14. * @package plist
  15. */
  16. class IOException extends Exception {
  17. /**
  18. * Flag telling the File could not be found
  19. */
  20. const NOT_FOUND = 1;
  21. /**
  22. * Flag telling the File is not readable
  23. */
  24. const NOT_READABLE = 2;
  25. /**
  26. * Flag telling the File is not writable
  27. */
  28. const NOT_WRITABLE = 3;
  29. /**
  30. * Flag telling there was a read error
  31. */
  32. const READ_ERROR = 4;
  33. /**
  34. * Flag telling there was a read error
  35. */
  36. const WRITE_ERROR = 5;
  37. /**
  38. * Create new IOException
  39. * @param string $path Source of the problem
  40. * @param integer $type Type of the problem
  41. */
  42. public function __construct($path, $type=null) {
  43. parent::__construct( $path, $type );
  44. }
  45. /**
  46. * Create new FileNotFound-Exception
  47. * @param string $path Source of the problem
  48. * @return IOException new FileNotFound-Exception
  49. */
  50. public static function notFound($path) {
  51. return new IOException( $path, self::NOT_FOUND );
  52. }
  53. /**
  54. * Create new FileNotReadable-Exception
  55. * @param string $path Source of the problem
  56. * @return IOException new FileNotReadable-Exception
  57. */
  58. public static function notReadable($path) {
  59. return new IOException( $path, self::NOT_READABLE );
  60. }
  61. /**
  62. * Create new FileNotWritable-Exception
  63. * @param string $path Source of the problem
  64. * @return IOException new FileNotWritable-Exception
  65. */
  66. public static function notWritable($path) {
  67. return new IOException( $path, self::NOT_WRITABLE );
  68. }
  69. /**
  70. * Create new ReadError-Exception
  71. * @param string $path Source of the problem
  72. * @return IOException new ReadError-Exception
  73. */
  74. public static function readError($path) {
  75. return new IOException( $path, self::READ_ERROR );
  76. }
  77. /**
  78. * Create new WriteError-Exception
  79. * @param string $path Source of the problem
  80. * @return IOException new WriteError-Exception
  81. */
  82. public static function writeError($path) {
  83. return new IOException( $path, self::WRITE_ERROR );
  84. }
  85. }
  86. ?>