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 Subversion repository here: http://svn.cocoasourcecode.com/FolderSweep, and Rainer will be putting a zip file of the current version up on his site later today.
If you’re not sure how to access a Subversion repository, just launch Terminal,
cd to wherever you want to keep the code, and then type this command:
You’ll get a copy of the code in your current working directory.
Send any bug reports or enhancement requests either to Rainer (preferably) or to me. Enjoy!