|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Tool |
|
17 * @subpackage Framework |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: Directory.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * @see Zend_Tool_Framework_Client_Storage_AdapterInterface |
|
25 */ |
|
26 require_once 'Zend/Tool/Framework/Client/Storage/AdapterInterface.php'; |
|
27 |
|
28 /** |
|
29 * @category Zend |
|
30 * @package Zend_Tool |
|
31 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
32 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
33 */ |
|
34 class Zend_Tool_Framework_Client_Storage_Directory |
|
35 implements Zend_Tool_Framework_Client_Storage_AdapterInterface |
|
36 { |
|
37 |
|
38 protected $_directoryPath = null; |
|
39 |
|
40 public function __construct($directoryPath) |
|
41 { |
|
42 if (!file_exists($directoryPath)) { |
|
43 throw new Zend_Tool_Framework_Client_Exception(__CLASS__ . ': the supplied directory does not exist'); |
|
44 } |
|
45 $this->_directoryPath = $directoryPath; |
|
46 } |
|
47 |
|
48 public function put($name, $value) |
|
49 { |
|
50 return file_put_contents($this->_directoryPath . DIRECTORY_SEPARATOR . $name, $value); |
|
51 } |
|
52 |
|
53 public function get($name) |
|
54 { |
|
55 return file_get_contents($this->_directoryPath . DIRECTORY_SEPARATOR . $name); |
|
56 } |
|
57 |
|
58 public function has($name) |
|
59 { |
|
60 return file_exists($this->_directoryPath . DIRECTORY_SEPARATOR . $name); |
|
61 } |
|
62 |
|
63 public function remove($name) |
|
64 { |
|
65 return unlink($this->_directoryPath . DIRECTORY_SEPARATOR . $name); |
|
66 } |
|
67 |
|
68 public function getStreamUri($name) |
|
69 { |
|
70 return $this->_directoryPath . DIRECTORY_SEPARATOR . $name; |
|
71 } |
|
72 |
|
73 } |