home *** CD-ROM | disk | FTP | other *** search
- /*
- File: FileOfFiles.h
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- #ifndef __FILEOFFILES__
- #define __FILEOFFILES__
-
- #ifndef __VIRTUALFILE__
- #include "VirtualFile.h"
- #endif
-
- #ifndef __OBJECTLIST__
- #include "ObjectList.h"
- #endif
-
- #pragma push
- #pragma segment FileOfFiles
-
- /***********************************|****************************************/
-
- class TFileOfFiles : public TVirtualFile
- {
- public:
- TFileOfFiles();
- virtual ~TFileOfFiles();
-
- unsigned long NumFiles() const;
- TVirtualFile* GetIndexFile ( unsigned long index ) const;
- unsigned long GetFileIndex( const TVirtualFile* ) const;
-
- OSErr AppendFile ( TVirtualFile* );
- OSErr InsertFile ( TVirtualFile*, unsigned long );
- TVirtualFile* RemoveIndexFile ( unsigned long );
-
- virtual OSErr ReadData ( void*, long& );
- virtual OSErr WriteData ( const void*, long& );
-
- virtual OSErr SetEnd ( long );
- virtual OSErr GetEnd ( long& ) const;
-
- virtual OSErr SetPosition ( short posMode, long posOff );
- virtual OSErr GetPosition ( long& ) const;
-
- OSErr Consolidate (); // integrates the subfiles into a single subfile
-
- virtual ostream& operator >> ( ostream& ) const;
-
- void InvalidateCache ();
-
- private: OSErr GetSubFile ( unsigned long position, TVirtualFile*& subFile, long& offsetInSubfile, unsigned long& subFileIndex, Boolean makeFiles );
- OSErr GetNextCacheFile ();
- unsigned long GetEnd () const;
-
- TVirtualFileList* fFileList;
- long fPosition;
-
- OSErr ValidateCache ( Boolean makeFile );
-
- TVirtualFile* fCacheFile;
- long fCacheOffset;
- unsigned long fCacheIndex;
-
- friend class TCacheCache;
- };
-
- /***********************************|****************************************/
-
- inline unsigned long TFileOfFiles::NumFiles() const { return fFileList->Count(); }
- inline TVirtualFile* TFileOfFiles::GetIndexFile(unsigned long index) const { return fFileList->Get(index); }
- inline unsigned long TFileOfFiles::GetFileIndex(const TVirtualFile* aFile) const { return fFileList->Find(aFile); }
-
- /***********************************|****************************************/
-
- #pragma pop
-
- #endif // defined __FILEOFFILES__
-