Path: utzoo!attcan!uunet!cs.utexas.edu!usc!wuarchive!swbatl!gilstrap From: gilstrap@swbatl.sbc.com (3929) Newsgroups: comp.lang.c++ Subject: Filesystem classes: how to? Message-ID: <1567@swbatl.sbc.com> Date: 7 Jun 90 13:23:25 GMT Reply-To: gilstrap@swbatl.UUCP (Brian Gilstrap - UCI - 5-3929) Organization: Southwestern Bell Tele. Co. - Advanced Technology Lab - St. Louis Lines: 37 Okay, anyone want to give a stab at a set of classes to implement a Unix file system? My initial thoughts were: FileSystemNode | +------------+--------------+-------+---------+ | | | | | Directory CharacterFile BlockFile Link SymbolicLink | +-------------------+ RegularFile CharacterSpecialFile However, since C++ won't let you cast down from a base class to a derived class, I can't open up a directory (which would ideally contain a set of FileSystemNodes), examine each entry, and work with it as the kind-of object it is. That is, if I'm wanting to traverse the directories and print out the name of each FileSystemNode and then recursively traverse all directories, how do I treat Directory objects as directory objects if directories contain FileSystemNodes (which means I can't get into Directories since they are only recognized as being a FileSystemNode). I suppose the Directory class could keep lists of CharacterFile's and BlockFile's and ... However, this means that the Directory class has to change each time a new derived class of FileSystemNode is created. Bad news. Anyone have any suggestions? Brian R. Gilstrap uucibg@swbatl.uucp OR ...!{ texbell, uunet }!swbatl!uucibg ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "You spend your whole life just piling it up there. You got stacks and stacks and stacks. Then Gabriel comes and taps you on the shoulder, but you don't see no hearses with luggage racks." --- Don Henley ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Copyright (c) 1990 by Brian R. Gilstrap. You may redistribute (my portions of) this material for free if and only if your recipients may also do so.