home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / VirtualFile / VirtualEnclosedBinaryMacFile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  4.9 KB  |  181 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        VirtualEnclosedBinaryMacFile.h
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef __VIRTUALENCLOSEDBINARYMACFILE__
  15. #define __VIRTUALENCLOSEDBINARYMACFILE__
  16.  
  17. #ifndef __VIRTUALMACFILE__
  18. #include "VirtualMacFile.h"
  19. #endif
  20.  
  21. /***********************************|****************************************/
  22.  
  23.  
  24. enum MBHeaderflds { kVers = 0,
  25.                     kFileNameLen = 1,
  26.                     kFileName = 2,
  27.                     kFileType = 65,
  28.                     kFileCreator = 69,
  29.                     kFinderFlgHi = 73,
  30.                     kVertPos = 75,
  31.                     kHorzPos = 77,
  32.                     kWinID = 79,
  33.                     kProtected = 81,
  34.                     kDFLength = 83,
  35.                     kRFLength = 87,
  36.                     kFileCrDate = 91,
  37.                     kFileMdDate = 95,
  38.                     kGetInfoComm = 99,
  39.                     kFinderFlgLo = 101,
  40.                     kTotalFileLen = 116,
  41.                     kLenSecHdr = 120,
  42.                     kMB2Version = 122,
  43.                     kMBMinVersion = 123,
  44.                     kCRC = 124,
  45.                     kEndMB2Head = 128
  46.                     };
  47.  
  48.  
  49. enum CCSHeaderflds { kCCSFnLen = 0,
  50.                      kCCSFname = 1,
  51.                      kCCSFType = 64,
  52.                      kCCSFCreator = 68,
  53.                      kCCSStop1 = 72,
  54.                      kCCSDFLength = 80,
  55.                      kCCSRFLength = 84,
  56.                      kCCSCDate = 88,
  57.                      kCCSModDate = 92,
  58.                      kEndCCSHead = 96
  59.                     };
  60.                     
  61. const    kHeaderSize = kEndMB2Head > kEndCCSHead ? kEndMB2Head : kEndCCSHead;
  62.  
  63. struct attachmentHeader        //general form for OutgoingBundle.cp  to use
  64. {
  65.     long             dataBytes;
  66.     long            dataForkPadBytes;
  67.     long             resBytes;
  68.     long            resourceForkPadBytes;
  69.     long            fileSize;
  70.     long             headerLength;
  71.     Str63             fName;
  72.     FInfo             fndrInfo;
  73.     char            enclosedFilePackerName[16];
  74.     unsigned char    header[kHeaderSize];
  75. };
  76.         
  77. //        struct macInfoHeader//CCSBinary 
  78. //        {
  79. //            Str63         fName;
  80. //            FInfo         fndrInfo;
  81. //            long         DataBytes;
  82. //            long         ResBytes;
  83. //            long         cDate;
  84. //            long         modDate;
  85. //        };
  86. //                
  87. //        struct macInfoHeaderMacBinary 
  88. //        {
  89. //            unsigned char        version;
  90. //            Str63                 fName;
  91. //            FInfo                 fndrInfo;
  92. //            unsigned char        protectedFlag;
  93. //            unsigned char        zeroFill;
  94. //            unsigned long         DataBytes;
  95. //            unsigned long         ResBytes;
  96. //            unsigned long         cDate;
  97. //            unsigned long         modDate;
  98. //            unsigned short        commentLength;
  99. //            unsigned char        finderFlagsLow;
  100. //            unsigned char        filler[14];
  101. //            unsigned long        totalFilesLength;
  102. //            unsigned short        secondaryHeaderLength;
  103. //            unsigned char        macBinaryVersion;
  104. //            unsigned char        macBinaryMinVersion;
  105. //            unsigned short        crc;
  106. //            unsigned char        filler2[2];        //should be 128 bytes total
  107. //        };
  108.  
  109. enum { kNoPacker = 0, kCCSBinary = 1, kMacBinaryII = 2 };
  110. enum { kMacBinaryVersion = 129, kBytesForCRC = 124 };        //miscellaneous constants
  111.  
  112. class TVirtualFile;
  113. class TFileInFile;
  114. unsigned short DoCRC (void *, short);
  115. extern void        SetUpEnclosedBinaryHeader(TVirtualMacFile *attachment, attachmentHeader& attachmentInfo, 
  116.                     unsigned long enclosedFilePacker, const CStr255& fileName);
  117.  
  118.  
  119. class TVirtualEnclosedBinaryMacFile  : public TVirtualMacFile
  120. {
  121. public:
  122.             TVirtualEnclosedBinaryMacFile(TVirtualFile* rawFile, unsigned long fEnclosedFilePacker);
  123.     virtual    ~TVirtualEnclosedBinaryMacFile();
  124.  
  125.     virtual Boolean                    IsValidEnclosedBinaryFile() const;
  126.     
  127.     virtual OSErr                     Open ();
  128.     virtual OSErr                     Close ();
  129.  
  130.     virtual OSErr                     ReadData (void* buffer,long& count,ForkType whichFork);
  131.     virtual OSErr                     WriteData (const void* buffer, long& count, ForkType whichFork);
  132.  
  133.     virtual OSErr                     SetEnd (long logEof, ForkType whichFork);
  134.     virtual OSErr                     GetEnd (long& logEof, ForkType whichFork) const;
  135.  
  136.     virtual OSErr                     SetPosition (short posMode, long posOff, ForkType whichFork);
  137.     virtual OSErr                     GetPosition (long& filePos,ForkType whichFork) const;
  138.  
  139.     virtual OSErr                     SetFinderInfo (const FInfo& finderInfo);
  140.     virtual OSErr                     GetFinderInfo (FInfo& finderInfo) const;
  141.  
  142.     virtual OSErr                     GetDate (unsigned long& dateTime,WhichDateType whichDate) const;
  143.     virtual OSErr                     SetDate (unsigned long dateTime,WhichDateType whichDate);
  144.  
  145.     virtual void                     SetUserRef(long ref);
  146.      virtual long                     GetUserRef() const;
  147.  
  148.     virtual OSErr                     SetFileName(const Str31 name);
  149.     virtual OSErr                     GetFileName(Str31 name) const;
  150.     
  151.     virtual    OSErr                    GetSpec ( FSSpec& ) const;
  152.     virtual    OSErr                    SetSpec ( const FSSpec& );
  153.  
  154. private:    TVirtualFile*            fFile;
  155.             TFileInFile*             fRFFile;
  156.             TFileInFile*             fDFFile;
  157.             unsigned long             fEnclosedFilePacker;
  158.             unsigned char             fFileInfoCCSBinary[kEndCCSHead];
  159.             unsigned char            fFileInfoMacBinary[kEndMB2Head];
  160.             Boolean                    fValidEnclosedBinaryFile;
  161.             unsigned char            fVersion;
  162.             Str63                     fName;
  163.             FInfo                     fFinderInfo;
  164.             long                     fDataBytes;
  165.             long                     fResBytes;
  166.             unsigned long             fCreationDate;
  167.             unsigned long             fModifiedDate;
  168.             unsigned short            fCRC;
  169.  
  170.             long                    fDataForkPadBytes;
  171.             long                    fResourceForkPadBytes;
  172.             long                    fHeaderSizeInVirtualFile;
  173.             short                    fSecondaryHeaderLength;
  174.  
  175. };
  176.  
  177. /***********************************|****************************************/
  178.  
  179. #endif    // __VIRTUALENCLOSEDBINARYMACFILE__
  180.  
  181.