| 1 |
<?php |
| 2 |
/** |
| 3 |
* Directory utilities. |
| 4 |
* |
| 5 |
* Copyright: © 2009-2011 |
| 6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.} |
| 7 |
* ( coded in the USA ) |
| 8 |
* |
| 9 |
* Released under the terms of the GNU General Public License. |
| 10 |
* You should have received a copy of the GNU General Public License, |
| 11 |
* along with this software. In the main directory, see: /licensing/ |
| 12 |
* If not, see: {@link http://www.gnu.org/licenses/}. |
| 13 |
* |
| 14 |
* @package s2Member\Utilities |
| 15 |
* @since 3.5 |
| 16 |
*/ |
| 17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"])) |
| 18 |
exit ("Do not access this file directly."); |
| 19 |
/**/ |
| 20 |
if (!class_exists ("c_ws_plugin__s2member_utils_dirs")) |
| 21 |
{ |
| 22 |
/** |
| 23 |
* Directory utilities. |
| 24 |
* |
| 25 |
* @package s2Member\Utilities |
| 26 |
* @since 3.5 |
| 27 |
*/ |
| 28 |
class c_ws_plugin__s2member_utils_dirs |
| 29 |
{ |
| 30 |
/** |
| 31 |
* Formulates basename dirs from a full directory path. |
| 32 |
* |
| 33 |
* This takes Windows® `\app_data\` sub-folders into consideration. |
| 34 |
* |
| 35 |
* @package s2Member\Utilities |
| 36 |
* @since 3.5 |
| 37 |
* |
| 38 |
* @param str $dir_path Directory path. |
| 39 |
* @return str Basename directory path; including a possible `\app_data\` directory. |
| 40 |
*/ |
| 41 |
public static function basename_dirs ($dir_path = FALSE) |
| 42 |
{ |
| 43 |
$dir_path = rtrim ($dir_path, DIRECTORY_SEPARATOR . "/"); |
| 44 |
/**/ |
| 45 |
$dir_path = preg_replace ("/(" . preg_quote (DIRECTORY_SEPARATOR, "/") . "|\/)app_data$/i", "", $dir_path, 1, $app_data); |
| 46 |
/**/ |
| 47 |
return basename ($dir_path) . (($app_data) ? "/app_data" : ""); |
| 48 |
} |
| 49 |
/** |
| 50 |
* Strips a trailing `\app_data\` sub-directory from the full path. |
| 51 |
* |
| 52 |
* @package s2Member\Utilities |
| 53 |
* @since 3.5 |
| 54 |
* |
| 55 |
* @param str $dir_path Directory path. |
| 56 |
* @return str Directory path without `\app_data\`. |
| 57 |
*/ |
| 58 |
public static function strip_dir_app_data ($dir_path = FALSE) |
| 59 |
{ |
| 60 |
$dir_path = rtrim ($dir_path, DIRECTORY_SEPARATOR . "/"); |
| 61 |
/**/ |
| 62 |
return preg_replace ("/(" . preg_quote (DIRECTORY_SEPARATOR, "/") . "|\/)app_data$/i", "", $dir_path, 1); |
| 63 |
} |
| 64 |
} |
| 65 |
} |
| 66 |
?> |