home *** CD-ROM | disk | FTP | other *** search
- /*
- File: VirtualEnclosedBinaryMacFile.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 __VIRTUALENCLOSEDBINARYMACFILE__
- #define __VIRTUALENCLOSEDBINARYMACFILE__
-
- #ifndef __VIRTUALMACFILE__
- #include "VirtualMacFile.h"
- #endif
-
- /***********************************|****************************************/
-
-
- enum MBHeaderflds { kVers = 0,
- kFileNameLen = 1,
- kFileName = 2,
- kFileType = 65,
- kFileCreator = 69,
- kFinderFlgHi = 73,
- kVertPos = 75,
- kHorzPos = 77,
- kWinID = 79,
- kProtected = 81,
- kDFLength = 83,
- kRFLength = 87,
- kFileCrDate = 91,
- kFileMdDate = 95,
- kGetInfoComm = 99,
- kFinderFlgLo = 101,
- kTotalFileLen = 116,
- kLenSecHdr = 120,
- kMB2Version = 122,
- kMBMinVersion = 123,
- kCRC = 124,
- kEndMB2Head = 128
- };
-
-
- enum CCSHeaderflds { kCCSFnLen = 0,
- kCCSFname = 1,
- kCCSFType = 64,
- kCCSFCreator = 68,
- kCCSStop1 = 72,
- kCCSDFLength = 80,
- kCCSRFLength = 84,
- kCCSCDate = 88,
- kCCSModDate = 92,
- kEndCCSHead = 96
- };
-
- const kHeaderSize = kEndMB2Head > kEndCCSHead ? kEndMB2Head : kEndCCSHead;
-
- struct attachmentHeader //general form for OutgoingBundle.cp to use
- {
- long dataBytes;
- long dataForkPadBytes;
- long resBytes;
- long resourceForkPadBytes;
- long fileSize;
- long headerLength;
- Str63 fName;
- FInfo fndrInfo;
- char enclosedFilePackerName[16];
- unsigned char header[kHeaderSize];
- };
-
- // struct macInfoHeader//CCSBinary
- // {
- // Str63 fName;
- // FInfo fndrInfo;
- // long DataBytes;
- // long ResBytes;
- // long cDate;
- // long modDate;
- // };
- //
- // struct macInfoHeaderMacBinary
- // {
- // unsigned char version;
- // Str63 fName;
- // FInfo fndrInfo;
- // unsigned char protectedFlag;
- // unsigned char zeroFill;
- // unsigned long DataBytes;
- // unsigned long ResBytes;
- // unsigned long cDate;
- // unsigned long modDate;
- // unsigned short commentLength;
- // unsigned char finderFlagsLow;
- // unsigned char filler[14];
- // unsigned long totalFilesLength;
- // unsigned short secondaryHeaderLength;
- // unsigned char macBinaryVersion;
- // unsigned char macBinaryMinVersion;
- // unsigned short crc;
- // unsigned char filler2[2]; //should be 128 bytes total
- // };
-
- enum { kNoPacker = 0, kCCSBinary = 1, kMacBinaryII = 2 };
- enum { kMacBinaryVersion = 129, kBytesForCRC = 124 }; //miscellaneous constants
-
- class TVirtualFile;
- class TFileInFile;
- unsigned short DoCRC (void *, short);
- extern void SetUpEnclosedBinaryHeader(TVirtualMacFile *attachment, attachmentHeader& attachmentInfo,
- unsigned long enclosedFilePacker, const CStr255& fileName);
-
-
- class TVirtualEnclosedBinaryMacFile : public TVirtualMacFile
- {
- public:
- TVirtualEnclosedBinaryMacFile(TVirtualFile* rawFile, unsigned long fEnclosedFilePacker);
- virtual ~TVirtualEnclosedBinaryMacFile();
-
- virtual Boolean IsValidEnclosedBinaryFile() const;
-
- virtual OSErr Open ();
- virtual OSErr Close ();
-
- virtual OSErr ReadData (void* buffer,long& count,ForkType whichFork);
- virtual OSErr WriteData (const void* buffer, long& count, ForkType whichFork);
-
- virtual OSErr SetEnd (long logEof, ForkType whichFork);
- virtual OSErr GetEnd (long& logEof, ForkType whichFork) const;
-
- virtual OSErr SetPosition (short posMode, long posOff, ForkType whichFork);
- virtual OSErr GetPosition (long& filePos,ForkType whichFork) const;
-
- virtual OSErr SetFinderInfo (const FInfo& finderInfo);
- virtual OSErr GetFinderInfo (FInfo& finderInfo) const;
-
- virtual OSErr GetDate (unsigned long& dateTime,WhichDateType whichDate) const;
- virtual OSErr SetDate (unsigned long dateTime,WhichDateType whichDate);
-
- virtual void SetUserRef(long ref);
- virtual long GetUserRef() const;
-
- virtual OSErr SetFileName(const Str31 name);
- virtual OSErr GetFileName(Str31 name) const;
-
- virtual OSErr GetSpec ( FSSpec& ) const;
- virtual OSErr SetSpec ( const FSSpec& );
-
- private: TVirtualFile* fFile;
- TFileInFile* fRFFile;
- TFileInFile* fDFFile;
- unsigned long fEnclosedFilePacker;
- unsigned char fFileInfoCCSBinary[kEndCCSHead];
- unsigned char fFileInfoMacBinary[kEndMB2Head];
- Boolean fValidEnclosedBinaryFile;
- unsigned char fVersion;
- Str63 fName;
- FInfo fFinderInfo;
- long fDataBytes;
- long fResBytes;
- unsigned long fCreationDate;
- unsigned long fModifiedDate;
- unsigned short fCRC;
-
- long fDataForkPadBytes;
- long fResourceForkPadBytes;
- long fHeaderSizeInVirtualFile;
- short fSecondaryHeaderLength;
-
- };
-
- /***********************************|****************************************/
-
- #endif // __VIRTUALENCLOSEDBINARYMACFILE__
-
-