Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

StatDir.H

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Last modified on Mon Nov 10 17:35:20 EST 2003 by ken@xorian.net
00020 //      modified on Fri Aug  8 19:53:51 PDT 1997 by heydon
00021 
00022 /* StatDir.H
00023 
00024    Defines objects and iterators at levels 4 and above of the stable cache
00025    hierarchy, namely, at the level of directories of either MPKFiles or sub-
00026    directories.
00027 */
00028 
00029 #ifndef _STAT_DIR_H
00030 #define _STAT_DIR_H
00031 
00032 #include <sys/types.h>
00033 #include <dirent.h>
00034 #include <Basics.H>
00035 #include <FS.H>
00036 #include "StatError.H"
00037 #include "StatDirEntry.H"
00038 #include "StatCount.H"
00039 #include "StatCollection.H"
00040 
00041 class DirIter; // defined below
00042 
00043 class DirObj : public DirEntry {
00044   public:
00045     DirObj(const Text& path) throw ()
00046       : DirEntry(DirEntry::Directory), path(path) { /*SKIP*/ }
00047     /* Create a new DirObj for the directory name "path". */
00048 
00049     int Search(int verbose, /*INOUT*/ Stat::Collection &stats)
00050       throw (StatError::UnevenLevels,
00051              StatError::BadMPKFile, StatError::EndOfFile,
00052              FS::Failure, FS::DoesNotExist);
00053     /* Search this DirObj, returning the height of the DirObj
00054        in the search tree. Update "entryStats" with statistical
00055        values at the leaves of the subtree rooted at this DirObj;
00056        update "fanout" at all levels at and below this DirObj with
00057        the fanout of each object in the subtree. */
00058 
00059   private:
00060     Text path; // pathname of the directory
00061     friend class DirIter;
00062 };
00063 
00064 class DirIter {
00065   public:
00066     DirIter(const DirObj *dirObj) throw (FS::Failure, FS::DoesNotExist);
00067     /* Initialize this iterator on the DirObj "dir". */
00068 
00069     bool Next(/*OUT*/ DirEntry* &entry)
00070       throw (StatError::EndOfFile, FS::Failure, FS::DoesNotExist);
00071     /* If the iterator is not finished, set "entry" to point to the next
00072        "DirEntry" in it and return true. Otherwise, return false. "entry"
00073        will actually point to one of the subtypes of "DirEntry", namely,
00074        "DirObj" or "MPKFileObj". The two types can be distinguished by
00075        the value of their common "kind" field. */
00076 
00077   private:
00078     Text path;                  // pathname for this directory ('/' at end)
00079     bool done;                  // indicates if iteration already finished
00080     DIR *dir;                   // underlying directory
00081 };
00082 
00083 #endif // _STAT_DIR_H

Generated on Mon May 8 00:48:36 2006 for Vesta by  doxygen 1.4.2