パス生成用関数 from Moony_Utils

function generatePath($dir, $file, $ext = null)
{
    $dir = rtrim($dir, DIRECTORY_SEPARATOR);
    $file = trim($file, DIRECTORY_SEPARATOR);
    $ext = ltrim($ext, '.');

    $path = '';
    if (strlen($dir) > 0) {
        $path = $dir . DIRECTORY_SEPARATOR . $file;
    } else {
        $path = $file;
    }
    if (strlen($ext) > 0) {
        $path = $path . '.' . $ext;
    }

    return $path;
}