summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaksymilian Osowski <maxosowski@google.com>2010-08-24 16:21:18 +0100
committerMaksymilian Osowski <maxosowski@google.com>2010-08-26 15:20:27 +0100
commitfae1cffa2447a0af2d3142ad0d351ef8935ef600 (patch)
tree574ddfca1ece8c2bebd9aaf17d48182d116cca26
parent911cbadd2256cdae7cab6eba74ff97cd115f260d (diff)
downloadexternal_webkit-fae1cffa2447a0af2d3142ad0d351ef8935ef600.zip
external_webkit-fae1cffa2447a0af2d3142ad0d351ef8935ef600.tar.gz
external_webkit-fae1cffa2447a0af2d3142ad0d351ef8935ef600.tar.bz2
Updated the script to allow for chosing the mode (list files vs. list folders).
Change-Id: I7a87e5591aef888f47cceaf3f30f5f2752e336aa
-rw-r--r--WebKitTools/DumpRenderTree/android/get_layout_tests_dir_contents.php69
1 files changed, 43 insertions, 26 deletions
diff --git a/WebKitTools/DumpRenderTree/android/get_layout_tests_dir_contents.php b/WebKitTools/DumpRenderTree/android/get_layout_tests_dir_contents.php
index 84b4ace..09f6b35 100644
--- a/WebKitTools/DumpRenderTree/android/get_layout_tests_dir_contents.php
+++ b/WebKitTools/DumpRenderTree/android/get_layout_tests_dir_contents.php
@@ -18,11 +18,13 @@
# Lists the content of the LayoutTests directory
#
# Usage:
-# get_layout_tests_dir_contents.php?path=PATH&recurse=RECURSE&separator=SEPARATOR
+# get_layout_tests_dir_contents.php?path=PATH&recurse=RECURSE&separator=SEPARATOR&mode=MODE
# where
# PATH - relative path in the LayoutTests dir
-# RECURSE = [1|0] (defaults to 1)
+# RECURSE = [true|false] (defaults to true)
# SEPARATOR = a string separating paths in result (defaults to \n)
+# MODE = [folders|files] (defaults to files) - if 'folders' then lists only folders,
+# if 'files' then only files
#Global variables
$rootDir =
@@ -43,7 +45,7 @@
return substr($basename, 0, 1) == '.';
}
- function getAllFilesUnderAsArray($relPath, $recurse) {
+ function getAllFilesUnderAsArray($relPath, $recurse, $mode) {
global $exclude;
global $rootDir;
$files = getFilesAsArray($relPath);
@@ -59,40 +61,55 @@
$filePath = $relPath . DIRECTORY_SEPARATOR . $value;
}
- if (!is_dir(getAbsolutePath($filePath))) {
+ if (is_dir(getAbsolutePath($filePath))) {
+ if ($mode == 'folders') {
+ $result = array_merge($result, (array)$filePath);
+ }
+ if ($recurse) {
+ $result = array_merge($result, getAllFilesUnderAsArray($filePath, $recurse, $mode));
+ }
+ } else if ($mode == 'files') {
$result = array_merge($result, (array)$filePath);
- } else if ($recurse) {
- $result = array_merge($result, getAllFilesUnderAsArray($filePath, $recurse));
}
}
return $result;
}
- $path = getAbsolutePath($_GET['path']);
+ function main() {
+ global $rootDir;
- if (isset($_GET['separator'])) {
- $separator = $_GET['separator'];
- } else {
- $separator = "\n";
- }
+ $path = getAbsolutePath($_GET['path']);
- if (!isset($_GET['recurse'])) {
- $_GET['recurse'] = True;
- }
+ if (!isset($_GET['separator'])) {
+ $separator = "\n";
+ } else {
+ $separator = $_GET['separator'];
+ }
- #Very primitive check if path tries to go above DOCUMENT_ROOT or is absolute
- if (strpos($_GET['path'], "..") !== False ||
- substr($_GET['path'], 0, 1) == DIRECTORY_SEPARATOR) {
- return;
- }
+ $recurse = (strtolower($_GET['recurse']) != 'false');
- #If we don't want realpath to append any prefixes we need to pass it an absolute path
- $path = realpath(getAbsolutePath($_GET['path']));
- $relPath = substr($path, strlen($rootDir) + 1);
+ if (strtolower($_GET['mode']) == 'folders') {
+ $mode = 'folders';
+ } else {
+ $mode = 'files';
+ }
- #If there is an error of some sort it will be output as a part of the answer!
- foreach (getAllFilesUnderAsArray($relPath, $_GET['recurse']) as $i => $value) {
- echo "$value$separator";
+ #Very primitive check if path tries to go above DOCUMENT_ROOT or is absolute
+ if (strpos($_GET['path'], "..") !== False ||
+ substr($_GET['path'], 0, 1) == DIRECTORY_SEPARATOR) {
+ return;
+ }
+
+ #If we don't want realpath to append any prefixes we need to pass it an absolute path
+ $path = realpath(getAbsolutePath($_GET['path']));
+ $relPath = substr($path, strlen($rootDir) + 1);
+
+ #If there is an error of some sort it will be output as a part of the answer!
+ foreach (getAllFilesUnderAsArray($relPath, $recurse, $mode) as $i => $value) {
+ echo "$value$separator";
+ }
}
+
+ main();
?>