[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Apply pattern-matching immediately beneath the stow director
From: |
Carl Fredrik Hammar |
Subject: |
Re: [PATCH] Apply pattern-matching immediately beneath the stow directory. |
Date: |
Tue, 8 Sep 2009 13:55:41 +0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Hi,
On Mon, Sep 07, 2009 at 11:24:48PM +0300, Sergiu Ivanov wrote:
> unionfs needs to explicitly enumerate the contents of a directory to
> do pattern matching in it. I cannot envision a way to do
> multi-component pattern matching without iterating all subdirectories
> of stow/ . Well, okay, there could be done some optimization (like
> counting the number of components in the pattern and not going deeper
> than that), but it does not change the concept considerably.
> BTW, the implied asterisk in the original implementation is achieved
> by explicitly going down to the second level under stow/ , i.e. it is
> hard-coded in the algorithm, not some patterns, filenames or anything
> else. Since this implementation didn't care about multi-component
> pattern, I chose not to think of them either.
>
> Do you have some general idea of how multi-component pattern matching
> could be implemented more efficiently than that? Some vague pointer
> should suffice for me to adapt the idea to unionfs.
How about matching one component at a time?
For instance, given `*/*/*' you iterate through all files in the
current directory and find matches to `*/' (the slash filters out
non-directories). For each match you recurse, making the match the
current directory and with the pattern with the tested component removed,
e.g. `*/*'. The recursion continues until the pattern is static or
there are no matches.
(Clarification: by current directory I don't mean the process' CWD,
just the directory currently being iterated.)
Regards,
Fredrik
- Re: [PATCH] Apply pattern-matching immediately beneath the stow directory., olafBuddenhagen, 2009/09/07
- Re: [PATCH] Apply pattern-matching immediately beneath the stow directory., Sergiu Ivanov, 2009/09/07
- Re: [PATCH] Apply pattern-matching immediately beneath the stow directory.,
Carl Fredrik Hammar <=
- Re: [PATCH] Apply pattern-matching immediately beneath the stow directory., Sergiu Ivanov, 2009/09/08
- Re: [PATCH] Apply pattern-matching immediately beneath the stow directory., Carl Fredrik Hammar, 2009/09/09
- Re: [PATCH] Apply pattern-matching immediately beneath the stow directory., Sergiu Ivanov, 2009/09/13
- Re: [PATCH] Apply pattern-matching immediately beneath the stow directory., olafBuddenhagen, 2009/09/23
- Re: [PATCH] Apply pattern-matching immediately beneath the stow directory., Sergiu Ivanov, 2009/09/23