Read Me About FinderListMode version 1.0.1 24 Oct 1997 This sample is designed to display a file hierarchy in a manner similar to the way the system 7 finder displays folders as lists. To do this, the project implements a datasource for the NSOutlineView class, and ties that data source to the file system through the NSFileManager class. Building the Code The code uses NSOutlineView, a new class in the Developer releases of Rhapsody; it will not compile under any previous versions of OpenStep. Restrictions In order to be as simple as possible, this code only displays the home directory of the person running the program. It would be lovely to allow the program to open and display arbitrary directories, double click on rows of the outlineview to open new windows, allow dragging and dropping between windows and stuff. However, for simplicity it does none of these things, though it should be easy to extend the code to do so. Other Code Notes There are two main classes in the program: FileInfo and FinderListModeController. FileInfo FileInfo objects are the Model of the system in a classic Model View Controller analysis. There is one FileInfo object for every file in the system. If the FileInfo object happens to be a directory, it contains a list of FileInfo objects, one for each of its children. To initialize a FileInfo object, you pass it its path. Information about the existence and number of children is gathered lazily Ð until the information is needed, it isn't extracted from the filesystem. The FileInfo gathers information about the file system through the NSFileManager class. It currently doesn't do anything intelligent with symbolic links, though this could easily be fixed. FinderListModeController The FinderListModeController is the object that interacts directly with the NSOutlineView as its datasource and the window as its delegate. In its role as datasource, the FinderListModeController takes data requests from the NSOutlineView, and passes them on to the appropriate FileInfo object. Making the FinderListModeController the delegate of the window allows the controller to quit the application when the window is closed. This also could have been done through the Application delegate method applicationShouldTerminateAfterLastWindowClosed: but I thought for cleaness it worked better this way. You may disagree. Known Bugs Because the FinderListModeController doesn't handle the delegate methods of the NSOutlineView, it is possible to edit the values of in the outlineview, such as changing the names of files, their modification dates and their types. However, changes are ignored and revert to previous values. Possible Future Enhancements Could reimplement the finder :-) Seriously, it would be very easy to allow multiple windows pointing at multiple directories, and to create new windows by double-clicking on entries in existing windows. It isn't clear what the best GUI for soft-links would be -- one possibility would make the titles of soft-links italicized, and allow them to be opened in the same way folders currently are allowed to open. Once information about a directory is gathered, it is never updated. Editing entries could rename files. Dragging and dropping between different windows or within a window could allow the movement of files. But I digress... Other Sources of Reference For more information about the NSOutlineView and NSFileManager, see their documentation. Version History 7/7/97 - v0.1 - sample created (Andy Wildenberg) 7/10/97 - v1.0 - first public version, with corrections suggested by Quinn and Randy Nelson. (Andy Wildenberg) 24 Oct 1997 - v1.0.1 - We now pass YES to the -[FileManager fileAttributesAtPath:traverseLinks:] in -[FileInfo initWithPath:] so symbolic links to directories will show up as directories, not files. This fixes Radar ID 1684665. I also added a makeKeyAndOrderFront: in the awakeFromNib so the main window shows up correctly when launched from Workspace. (Quinn "The Eskimo!") 26 Jun 1998 - v1.0.1 - Move the creation of the data structure representing the top node out of awakeFromNib: (which is too late) into an init: method. (DGrits) Andy Wildenberg Apple Developer Technical Support Ceiling Support Technician and Curriculum Developer