You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered a case where I'd like to do a breadth-first traversal of a directory structure, and I don't see a way to do this with fs/walk as it currently stands.
My use case: I have a directory tree full of XML files representing various books and magazine articles. Each one has a cover page, linked to by an img element near the top of the XML file, and I'm trying to present a view to the user that shows some basic metadata: cover image, title, author, that sort of thing. Thing is, while the original directory structure had the cover images in the same directory as the content (and the img element in the XML has a src attribute with no path in it), some kind soul has "helpfully" reorganized the directory structure to collect all the cover images together. And while I could just hard-code the cover image directory into my code, that feels like the wrong solution to me: what if it changes again? I can't be constantly tweaking this code; it needs to Just Work.
So I want to do a fs/walk of the directory structure, starting from the library-root directory, to find the cover images. Thing is, there are several hundred directories in the tree, arranged something like this:
Except it's more like six hundred bookNNN directories, not just six. A breadth-first traversal would find the right directory FAR sooner than a depth-first traversal would.
Unfortunately, I don't have quite enough Clojure expertise at this point to code it myself, or I would just write it and submit a pull request. But I would really like to see a breadth-first option for directory walking.
The text was updated successfully, but these errors were encountered:
I've encountered a case where I'd like to do a breadth-first traversal of a directory structure, and I don't see a way to do this with fs/walk as it currently stands.
My use case: I have a directory tree full of XML files representing various books and magazine articles. Each one has a cover page, linked to by an img element near the top of the XML file, and I'm trying to present a view to the user that shows some basic metadata: cover image, title, author, that sort of thing. Thing is, while the original directory structure had the cover images in the same directory as the content (and the img element in the XML has a src attribute with no path in it), some kind soul has "helpfully" reorganized the directory structure to collect all the cover images together. And while I could just hard-code the cover image directory into my code, that feels like the wrong solution to me: what if it changes again? I can't be constantly tweaking this code; it needs to Just Work.
So I want to do a fs/walk of the directory structure, starting from the library-root directory, to find the cover images. Thing is, there are several hundred directories in the tree, arranged something like this:
library-root/category1/book001
library-root/category1/book002
library-root/category1/book003
library-root/category2/book001
library-root/category2/book002
library-root/category2/book003
library-root/cover-images
Except it's more like six hundred bookNNN directories, not just six. A breadth-first traversal would find the right directory FAR sooner than a depth-first traversal would.
Unfortunately, I don't have quite enough Clojure expertise at this point to code it myself, or I would just write it and submit a pull request. But I would really like to see a breadth-first option for directory walking.
The text was updated successfully, but these errors were encountered: