public static function listFilesInFolder($strPath, $blnSkipFolders = true, $strFilenamePattern = null)
    {
        // strip off the trailing slash if it's there
        if ($strPath[strlen($strPath) - 1] == "/") {
            $strPath = substr($strPath, 0, -1);
        }

        $result = array();

        $originalSet = self::getFilesInFolderHelper($strPath);
        if (!$originalSet) {
            return $result;
        }    // empty directory, or directory does not exist

        foreach ($originalSet as $item) {
            $childPath = $strPath . "/" . $item;
            if (is_dir($childPath)) {
                $childItems = self::listFilesInFolder($childPath);
                foreach ($childItems as $child) {
                    $result[] = $item . "/" . $child;
                }
            }

            if (!$blnSkipFolders || !is_dir($childPath)) {
                if (!$strFilenamePattern || ($strFilenamePattern && preg_match($strFilenamePattern, $item))) {
                    $result[] = $item;
                }
            }
        }

        return $result;
    }