Re: How to get list of output of find command of Linux

new topic     » goto parent     » topic index » view thread      » older message » newer message
rneu said...

Thanks for a very clear code.

Why are you against recursion?

I'm not against recursion per se, but it's not really a good approach for scanning through a file system. With any programming language, but especially interpreted ones like Euphoria, deeply recursive functions create additional overhead, and file systems tend to be deeply recursive, so there's a potential for lots of overhead.

Alternatively, if it applies to your project, what I'd recommend is using a queued approach like I've shown, but combine that with a visitor function like walk_dir() uses, so that you don't collect all the file names you've found in memory. I can provide an example on how to do that if you need.

In the end, the "best" method for this is probably an iterator that holds its position in the queue and only returns the values as they're requested. Other languages have this feature, like Python, and it's a pretty neat, albeit complicated, way to run through a list of items very efficiently.

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu