function stsGetFileListing pFolder,pFilterType,pIsRecursive,pIncludeInvisible
put ((pIsRecursive <> "false") and (pIsRecursive <> "")) into tRecursive
put ((pIncludeInvisible <> "false") and (pIncludeInvisible <> "")) into tIncludeInvisible
if there is a folder pFolder then
put the directory into tOldDir
put _stsWalkDir(pFolder,pFilterType,tRecursive,tIncludeInvisible) into tList
replace "//" with "/" in tList
set the directory to tOldDir
if pFilterType <> "" then
switch (the platform)
case "MacOS"
if "." is not in pFilterType then
-- assume Mac Type Code
filter tList with ("*" & pFilterType)
replace (tab & pFilterType) with "" in tList
else
-- assume file extension
filter tList with ("*" & pFilterType & tab & "*")
put cr after tList
put replaceText(tList,tab&".*\n",CR) into tList
if last char of tList is CR then delete last char of tList
end if
default
if char 1 of pFilterType <> "." then put "." before pFilterType
filter tList with ("*" & pFilterType)
return tList
break
end switch
else
return tList
end if
else
return "Error: Folder does not exist at '" & pFolder & "'."
end if
end stsGetFileListing
function _stsWalkDir pPath,pFilterType,pRecursive,pIncludeInvisible
put empty into tRetVal
set the directory to pPath
put 0 into tItemCount
put the long files into tFiles
if tFiles <> "" then
repeat for each line tFile in tFiles
if (pFilterType <> "") and (the platform is "MacOS") then
put urlDecode(item 1 of tFile) & tab & (item -1 of tFile) into tData
else
put urlDecode(item 1 of tFile) into tData
end if
if (tFile <> ".") and (tFile <> "..") then
if pIncludeInvisible <> "true" then
if char 1 of tFile <> "." then
put pPath & "/" & tData & cr after tRetVal
add 1 to tItemCount
end if
else
put pPath & "/" & tData & cr after tRetVal
add 1 to tItemCount
end if
end if
end repeat
end if
if pRecursive <> "true" then return tRetVal
put the folders into tFolders
repeat for each line tFolder in tFolders
if (tFolder <> ".") and (tFolder <> "..") then
if pIncludeInvisible <> "true" then
if char 1 of tFolder <> "." then
add 1 to tItemCount
put _stsWalkDir(pPath & "/" & tFolder,pFilterType,pRecursive,pIncludeInvisible) after tRetVal
end if
else
add 1 to tItemCount
put _stsWalkDir(pPath & "/" & tFolder,pFilterType,pRecursive,pIncludeInvisible) after tRetVal
end if
end if
end repeat
if tItemCount = 0 then
-- folder has nothing to display
put pPath & "/" & cr after tRetVal
end if
return tRetVal
end _stsWalkDir