1<?php
2/**
3 * File containing the ezcBaseFileIoException class
4 *
5 * @package Base
6 * @version 1.8
7 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
8 * @license http://ez.no/licenses/new_bsd New BSD License
9 */
10/**
11 * ezcBaseFileIoException is thrown when a problem occurs while writing
12 * and reading to/from an open file.
13 *
14 * @package Base
15 * @version 1.8
16 */
17class ezcBaseFileIoException extends ezcBaseFileException
18{
19    /**
20     * Constructs a new ezcBaseFileIoException for the file $path.
21     *
22     * @param string $path The name of the file.
23     * @param int    $mode The mode of the property that is allowed
24     *               (ezcBaseFileException::READ, ezcBaseFileException::WRITE,
25     *               ezcBaseFileException::EXECUTE or
26     *               ezcBaseFileException::CHANGE).
27     * @param string $message A string with extra information.
28     */
29    function __construct( $path, $mode, $message = null )
30    {
31        switch ( $mode )
32        {
33            case ezcBaseFileException::READ:
34                $operation = "An error occurred while reading from '{$path}'";
35                break;
36            case ezcBaseFileException::WRITE:
37                $operation = "An error occurred while writing to '{$path}'";
38                break;
39        }
40
41        $messagePart = '';
42        if ( $message )
43        {
44            $messagePart = " ($message)";
45        }
46
47        parent::__construct( "$operation.$messagePart" );
48    }
49}
50?>
51