in reply to Re^3: Reinvent the wheel!
in thread Reinvent the wheel!
In my case, though, what was I supposed to read?
Fair enough. In your case, a good POSIX or Unix book which describes how filesystems work. In particular, some of the grottiest code in File::Find detects such weirdnesses as recursive symbolic and hard links that can turn a nice tree structure into a complex graph with cyclic relationships. That's a common enough situation that will not be obvious to most autodidacts trying to deal with this sort of problem.
How about dealing with orphaned symlinks? Non-regular files? Mount points? Overlays?
It's also a very common problem in graph traversal, of which "How do I find files under this directory according to some pattern?" is a refinement.
I kept thinking about the general problem that file system crawling presents....
Of course. This is a good example and learning opportunity. By no means do I mean to suggest otherwise. Yet a robust solution to the problem is far more complex than you might suspect.
Perhaps I'm reacting poorly to the phrase "reinventing the wheel", which connotes to me that you've examined the existing solutions and found them lacking in some means. (In my experience, the people who claim that they have really haven't, not in any detail.) Perhaps I've misunderstood you.
If I understand you correctly, you're saying that my time would have been better spent reading through the code in File::Find. Is that your point?
In specific, I can't recommend reading that code. It's not great. It does, however, address a lot of problems that occur in the real world that a robust filesystem walker does need to address. What's a good way of agreeing to the general question but backing off from the specifics?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Reinvent the wheel!
by telemachus (Friar) on Mar 22, 2009 at 04:12 UTC |