Some new source code for you, this time from my esteemed colleague Rainer “RBSplitView” Brockerhoff, in collusion with myself. The code is called FolderSweep, and in a nutshell it shows you how to recursively traverse a folder-hierarchy really quickly (faster than using NSFileManager) and in a controlled way, optionally also memory-mapping the contents of files and providing them to your delegate object.
The code shows how to:
- Easily set up a FolderSweeper in a given folder (choosing whether to follow symlinks/aliases or not).
- Approve or reject further processing of files/folders as necessary.
- Determine whether a given file conforms to a given UTI (Uniform Type Identifier), in this case text.
- Retrieve the memory-mapped contents of files.
- Perform text encoding-detection (or sniffing) to determine how to interpret the text file.
- And quite probably more.
We’ve commented the class and also the demo code quite heavily, so it should be immediately useful. You can always grab the latest version of the code from my public github repository here: https://github.com/mattgemmell/FolderSweep, and Rainer will be putting a zip file of the current version up on his site later today.
Send any bug reports or enhancement requests either to Rainer (preferably) or to me. Enjoy!