1: <?php
2: /**
3: * RCS directory class that stores information about the files in a single
4: * directory in the repository.
5: *
6: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (LGPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
10: *
11: * @author Jan Schneider <jan@horde.org>
12: * @package Vcs
13: */
14: class Horde_Vcs_Directory_Rcs extends Horde_Vcs_Directory_Base
15: {
16: /**
17: * Constructor.
18: *
19: * @param Horde_Vcs_Base $rep A repository object.
20: * @param string $dn Path to the directory.
21: * @param array $opts Any additional options:
22: *
23: * @throws Horde_Vcs_Exception
24: */
25: public function __construct(Horde_Vcs_Base $rep, $dn, $opts = array())
26: {
27: parent::__construct($rep, $dn, $opts);
28: $dir = $rep->sourceroot . $this->_dirName;
29:
30: /* Make sure we are trying to list a directory */
31: if (!@is_dir($dir)) {
32: throw new Horde_Vcs_Exception('Unable to find directory: ' . $dir);
33: }
34:
35: /* Open the directory for reading its contents */
36: if (!($handle = @opendir($dir))) {
37: throw new Horde_Vcs_Exception(empty($php_errormsg) ? 'Permission denied' : $php_errormsg);
38: }
39:
40: /* Create two arrays - one of all the files, and the other of all the
41: * directories. */
42: while (($name = readdir($handle)) !== false) {
43: if (($name == '.') || ($name == '..')) {
44: continue;
45: }
46:
47: $path = $dir . '/' . $name;
48: if (@is_dir($path)) {
49: /* Skip Attic directory. */
50: if ($name != 'Attic') {
51: $this->_dirs[] = $name;
52: }
53: } elseif (@is_file($path) && (substr($name, -2) == ',v')) {
54: /* Spawn a new file object to represent this file. */
55: $this->_files[] = $rep->getFile(
56: substr($path, strlen($rep->sourceroot), -2));
57: }
58: }
59:
60: /* Close the filehandle; we've now got a list of dirs and files. */
61: closedir($handle);
62: }
63: }
64: