Annotation of fam/fam/DirectoryScanner.h, Revision 1.1
1.1 ! trev 1: // Copyright (C) 1999 Silicon Graphics, Inc. All Rights Reserved.
! 2: //
! 3: // This program is free software; you can redistribute it and/or modify it
! 4: // under the terms of version 2 of the GNU General Public License as
! 5: // published by the Free Software Foundation.
! 6: //
! 7: // This program is distributed in the hope that it would be useful, but
! 8: // WITHOUT ANY WARRANTY; without even the implied warranty of
! 9: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, any
! 10: // license provided herein, whether implied or otherwise, is limited to
! 11: // this program in accordance with the express provisions of the GNU
! 12: // General Public License. Patent licenses, if any, provided herein do not
! 13: // apply to combinations of this program with other product or programs, or
! 14: // any other product whatsoever. This program is distributed without any
! 15: // warranty that the program is delivered free of the rightful claim of any
! 16: // third person by way of infringement or the like. See the GNU General
! 17: // Public License for more details.
! 18: //
! 19: // You should have received a copy of the GNU General Public License along
! 20: // with this program; if not, write the Free Software Foundation, Inc., 59
! 21: // Temple Place - Suite 330, Boston MA 02111-1307, USA.
! 22:
! 23: #ifndef DirectoryScanner_included
! 24: #define DirectoryScanner_included
! 25:
! 26: #include "Scanner.h"
! 27:
! 28: #include <stddef.h>
! 29: #include <sys/types.h>
! 30: #include <sys/dir.h>
! 31:
! 32: #include "Event.h"
! 33:
! 34: class Client;
! 35: class Directory;
! 36: class DirEntry;
! 37:
! 38: // DirectoryScanner scans a directory for created or deleted files.
! 39: // It is an object because a scan can be interrupted when the output
! 40: // stream becomes blocked.
! 41: //
! 42: // The interface is quite weird. Each time the done() method is called,
! 43: // it does as much work as it can, until output is blocked. Then
! 44: // it returns true or false depending on whether it got done.
! 45: //
! 46: // This whole flow control thing needs a good redesign.
! 47: //
! 48: // Since a large number of DirectoryScanners is created, we have our
! 49: // own new and delete operators. They cache the most recently freed
! 50: // DirectoryScanner for re-use.
! 51:
! 52: class DirectoryScanner : public Scanner {
! 53:
! 54: public:
! 55:
! 56: typedef void (*DoneHandler)(void *closure);
! 57:
! 58: DirectoryScanner(Directory&, const Event&, bool, DoneHandler, void *);
! 59: virtual ~DirectoryScanner();
! 60:
! 61: virtual bool done();
! 62:
! 63: void *operator new (size_t);
! 64: void operator delete (void *);
! 65:
! 66: private:
! 67:
! 68: // Instance Variables
! 69:
! 70: Directory& directory;
! 71: const DoneHandler done_handler;
! 72: void *const closure;
! 73: const Event& new_event;
! 74: const bool scan_entries;
! 75: DIR *dir;
! 76: int openErrno;
! 77: DirEntry **epp;
! 78: DirEntry *discard;
! 79:
! 80: // Class Variable
! 81:
! 82: static DirectoryScanner *cache;
! 83:
! 84: // Private Instance Methods
! 85:
! 86: DirEntry **match_name(DirEntry **epp, const char *name);
! 87:
! 88: };
! 89:
! 90: #endif /* !DirectoryScanner_included */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>