Re: [code] [textadept] lfs.dir_foreach and symlinks

From: Mitchell <m.att.foicica.com>
Date: Thu, 9 Apr 2015 12:50:52 -0400 (EDT)

Hi,

On Thu, 9 Apr 2015, Rena wrote:

> On Thu, Apr 9, 2015 at 12:41 PM, Mitchell <m.att.foicica.com> wrote:
>> Hi Chris,
>>
>> On Thu, 9 Apr 2015, Chris Emerson wrote:
>>
>>> Hi,
>>>
>>> I want to do something like lfs.dir_foreach, but with the option to
>>> somehow
>>> skip symlinked directories. As far as I can see, there's no good way to
>>> do
>>> that at the moment.
>>>
>>> The closest is returning false from the provided function (which would
>>> call
>>> lfs.symlinkattributes)- but that skips the rest of the entries in the same
>>> directory as the symlink rather than just skipping that item
>>> (incidentally,
>>> I'm not sure that's exactly what I expected from the documentatin).
>>>
>>> My problem would be solved by allowing the function to return some other
>>> value (eg "skip") which meant "don't recurse into this directory, but
>>> continue"; or some extension to the filter table to let me do something
>>> similar (maybe cleaner).
>>>
>>> Have I missed a better solution?
>>
>>
>> No, you outlined pretty much what needs to be done. I'll think on this and
>> let you know what I come up with.
>>
>> Cheers,
>> Mitchell
>> --
>> You are subscribed to code.att.foicica.com.
>> To change subscription settings, send an e-mail to code+help.att.foicica.com.
>> To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
>>
>
> I wonder why dir_foreach itself is recursive? If it only listed the
> specified directory itself, then it'd be trivial to check if an entry
> is a non-symlinked directory, and if so, manually recurse into it.

Simply because the recursion is quite useful -- Textadept itself makes
good use of it. However, if you wanted to manually iterate in the way you
described, you can pass n=0 for the recursion depth.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Thu 09 Apr 2015 - 12:50:52 EDT

This archive was generated by hypermail 2.2.0 : Fri 10 Apr 2015 - 06:26:48 EDT