folderbot is released under my sharewear license: I share, you wear. You can use the code for whatever you like and if you make money out of it, keep it. If it breaks, you get to keep the broken bits. If you don't like it, you can have your money back.
Enough with the legal stuff and onto it:
The folderbot class is simple yet very useful. It goes through a given folder path triggerring class-based events. For example, every time a new folder is found, the folder_event() method is called. Whatever you have made folder_event() do will happen in your program.
The intent was to use folderbot as a base class for folder-based jobs and extend it functionality into derived classes which custom-handle the events.
The simplest way to use the class is included as an example. It is ready to work off the box and just prints the file names. Just change the starting path to somewhere on your own puter or web server.
The core functionality that I intended to encapsulate in the class is the following:
- automatic detection of the folder entries . and .. (they are just skipped)
- switcheable recursion. You can do the current folder as well as all sub-folders if required.
- file filtring
Basically, what this class could do for you is shield you from the process of writing code to list files in a folder.
There were plenty of good dir classes around but none really did what I wanted. I like fairly clean OOP design and I don't usually like messing with code others have written.
It's fairly obvious how you could improve it and if you did, I would appreciate a copy of the new class and we could post it as another version of folderbot for others to use. If you find a nasty thing in here, let me know.
I wrote this stuff in a hurry, sorry if it sounds a bit confused. Run the example, it's worth a thousand words.
Plenty of Hot Programming to yous all!