/**
 * Gets the path to a Reason library file.
 * Returns the path to the file in the local directory if it exists, otherwise
 * the path to the file in the core directory if that exists, otherwise null.
 * @param string path inside the local or core directory
 * @param string $section "lib" is the default and nothing else is supported right now
 * @return string the path to the file, or NULL if it wasn't found
 */
function reason_resolve_path($path, $section = "lib")
{
    $resolved = reason_get_local_path($path, $section);
    if (file_exists($resolved)) {
        return $resolved;
    }
    $resolved = reason_get_core_path($path, $section);
    if (file_exists($resolved)) {
        return $resolved;
    }
    return null;
}
Пример #2
0
/**
 * Returns the path components after /reason_package/
 * 
 * @param string full_path - absolute path
 * @param string suffix - extension to strip
 *
 * @return string
 */
function reason_basename($full_path, $suffix = '.php')
{
    // if the pathname does not appear to be in the reason include we do some symlink hocus pocus.
    if (carl_strpos($full_path, REASON_INC) === FALSE) {
        // first try local
        $local_path = reason_get_local_path("");
        $real_local_path = realpath($local_path);
        if (carl_substr($real_local_path, -1) != '/') {
            $real_local_path = $real_local_path . "/";
        }
        // add trailing slash.
        if (carl_strpos($full_path, $real_local_path) !== FALSE) {
            return carl_basename($local_path . carl_substr($full_path, carl_strlen($real_local_path)), $suffix, '/reason_package/');
        }
        // now try core
        $core_path = reason_get_core_path("");
        $real_core_path = realpath($core_path);
        if (carl_substr($real_core_path, -1) != '/') {
            $real_core_path = $real_core_path . "/";
        }
        // add trailing slash.
        if (carl_strpos($full_path, $real_core_path) !== FALSE) {
            return carl_basename($local_path . carl_substr($full_path, carl_strlen($real_core_path)), $suffix, '/reason_package/');
        }
    }
    return carl_basename($full_path, $suffix, '/reason_package/');
}
Пример #3
0
/**
 * Checks to make sure the given file exists in either the core or the local
 * directories.
 * @param string $path Path inside the local and/or core directories
 * @param string $section "lib" is the default
 * @return boolean true if the file exists; false if otherwise
 * @author Eric Naeseth <*****@*****.**>
 */
function reason_file_exists($path, $section = "lib")
{
    return file_exists(reason_get_core_path($path, $section)) || file_exists(reason_get_local_path($path, $section));
}