source-class-Com.Tecnick.File.Dir

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
 1: <?php
 2: /**
 3:  * Dir.php
 4:  *
 5:  * @since       2015-07-28
 6:  * @category    Library
 7:  * @package     File
 8:  * @author      Nicola Asuni <info@tecnick.com>
 9:  * @copyright   2015-2015 Nicola Asuni - Tecnick.com LTD
10:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
11:  * @link        https://github.com/tecnickcom/tc-lib-file
12:  *
13:  * This file is part of tc-lib-file software library.
14:  */
15: 
16: namespace Com\Tecnick\File;
17: 
18: use \Com\Tecnick\File\Exception as FileException;
19: 
20: /**
21:  * Com\Tecnick\File\Dir
22:  *
23:  * Function to read byte-level data
24:  *
25:  * @since       2015-07-28
26:  * @category    Library
27:  * @package     File
28:  * @author      Nicola Asuni <info@tecnick.com>
29:  * @copyright   2015-2015 Nicola Asuni - Tecnick.com LTD
30:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
31:  * @link        https://github.com/tecnickcom/tc-lib-file
32:  */
33: class Dir
34: {
35:     /**
36:      * Returns the full path of a parent directory
37:      *
38:      * @param string $name Name of the parent folder to search
39:      * @param string $dir  Starting directory
40:      *
41:      * @return string Directory name
42:      */
43:     public function findParentDir($name, $dir = __DIR__)
44:     {
45:         while (!empty($dir)) {
46:             if ($dir == '/') {
47:                 $dir = '';
48:             }
49:             if (@is_writable($dir.'/'.$name)) {
50:                 $dir = $dir.'/'.$name;
51:                 break;
52:             }
53:             $dir = dirname($dir);
54:         }
55:         if (substr($dir, -1) !== '/') {
56:             $dir .= '/';
57:         }
58:         return $dir;
59:     }
60: }
61: 
 

© 2004-2017 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy