Hi, On Tue, Sep 8, 2009 at 1:55 PM, Carl Fredrik Hammar wrote: >> 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.)
Just realized that there are many programs that do this pattern matching, and indeed glibc's glob() does exactly this. It even has some extensions so that it can be used on structures other than directories. Forget what I said and just use glob(). Regards, Fredrik