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

From: Mitchell <m.att.foicica.com>
Date: Mon, 13 Apr 2015 15:56:28 -0400 (EDT)

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?

I've committed a change[1] that allows you to set a `symlink` flag for
files and folders to filter out. The function called by
`lfs.dir_foreach()` wasn't designed to do the job of a filter.

   lfs.dir_foreach('/path', function(file)
     ...
   end, {folders = {symlink = true}})

should do what you're looking for -- filtering out symlinked directories.

Cheers,
Mitchell

[1]: http://foicica.com/hg/textadept/rev/138709b79e91

-- 
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 Mon 13 Apr 2015 - 15:56:28 EDT

This archive was generated by hypermail 2.2.0 : Tue 14 Apr 2015 - 06:33:30 EDT