How to resolve the algorithm Walk a directory/Recursively step by step in the LiveCode programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Walk a directory/Recursively step by step in the LiveCode programming language
Table of Contents
Problem Statement
Walk a given directory tree and print files matching a given pattern.
Note: This task is for recursive methods. These tasks should read an entire directory tree, not a single directory.
Note: Please be careful when running any code examples found here.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Walk a directory/Recursively step by step in the LiveCode programming language
Source code in the livecode programming language
function pathsForDirectoryAndWildcardPattern pDirectory, pWildcardPattern
-- returns a return-delimited list of long file names
-- the last character in the list is a return, unless the list is empty
filter files(pDirectory) with pWildcardPattern
repeat for each line tFile in it
put pDirectory & slash & tFile & cr after tPaths
end repeat
filter folders(pDirectory) without ".."
repeat for each line tFolder in it
put pathsForDirectoryAndWildcardPattern(pDirectory & slash & tFolder, pWildcardPattern) after tPaths
end repeat
return tPaths
end pathsForDirectoryAndWildcardPattern
put pathsForDirectoryAndWildcardPattern(the documents folder, "*.livecode*"
You may also check:How to resolve the algorithm Read a configuration file step by step in the Visual Basic programming language
You may also check:How to resolve the algorithm Classes step by step in the EMal programming language
You may also check:How to resolve the algorithm Program termination step by step in the C# programming language
You may also check:How to resolve the algorithm A+B step by step in the HicEst programming language
You may also check:How to resolve the algorithm Continued fraction/Arithmetic/Construct from rational number step by step in the C++ programming language