home *** CD-ROM | disk | FTP | other *** search
- /*
- File: UpdatCtr.cpp
-
- Contains: Implementation of ODMemContainer class.
-
- Owned by: Vincent Lo
-
- Copyright: © 1995 - 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <4> 8/13/96 DM 1376080: TempSuppressFatalBentoError
- spelling
- <3> 5/24/96 jpa 1246074: SOM_CATCH --> SOM_TRY..SOM_ENDTRY
- <2> 5/23/96 DH 1344338: Force quit of document when
- dragging 'Bad' file or Container. Turned
- off fatal Bento errors for Open and Create
- container operations.
-
- To Do:
- In Progress:
-
- */
-
- #define ODUpdateContainer_Class_Source
-
- #define VARIABLE_MACROS
-
- #include <UpdatCtr.xih>
-
- #ifndef _PLFMDEF_
- #include "PlfmDef.h"
- #endif
-
- #ifndef SOM_ODStorageSystem_xh
- #include <ODStor.xh>
- #endif
-
- #ifndef SOM_CMDocument_xh
- #include <CMDoc.xh>
- #endif
-
- #ifndef _MEMHDR_
- #include "MemHdr.h"
- #endif
-
- #ifndef _TARGTHDR_
- #include "TargtHdr.h"
- #endif
-
- #ifndef __CM_API__
- #include "CMAPI.h"
- #endif
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- #ifndef _ODNEW_
- #include <ODNew.h>
- #endif
-
- #ifndef _STORUTIL_
- #include <StorUtil.h>
- #endif
-
- #ifndef _PLFMFILE_
- #include <PlfmFile.h>
- #endif
-
- #ifndef _BARRAY_
- #include <BArray.h>
- #endif
-
- #ifndef _ODMEMORY_
- #include <ODMemory.h>
- #endif
-
- #ifndef _BENTOSUPPRESS_
- #include <BentoSuppress.h>
- #endif
-
- #pragma segment ODUpdateContainer
-
- //==============================================================================
- // ODUpdateContainer
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // ODUpdateContainer: ~ODUpdateContainer
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODUpdateContainersomUninit(ODUpdateContainer *somSelf)
- {
- ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
- ODUpdateContainerMethodDebug("ODUpdateContainer","somUninit");
-
- ODSafeReleaseObject(_fTargetDocument);
- ODSafeReleaseObject(_fTargetContainer);
-
- ODDisposeHandle(_fHandle);
- }
-
- //------------------------------------------------------------------------------
- // ODUpdateContainer: InitContainer
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODUpdateContainerInitContainer(ODUpdateContainer *somSelf, Environment *ev,
- ODStorageSystem* storage, ODContainerID* id)
- {
- ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
- ODUpdateContainerMethodDebug("ODUpdateContainer","InitContainer");
-
- SOM_TRY
-
- /* Moved from somInit. SOM itself sets fields to zero
- _fTargetContainer = kODNULL;
- _fTargetDocument = kODNULL;
- _fHandle = kODNULL;
- */
-
- ODBoolean fileLocked = kODTrue;
- PlatformFile file;
-
- ODVolatile(fileLocked);
- TRY
- file.Specify((FSSpec*) id->_buffer);
- fileLocked = file.IsLocked();
- if (fileLocked == kODFalse)
- file.Lock();
-
- {
- TempSuppressFatalBentoError temp;
-
- _fTargetContainer = (ODBentoContainer*) GetFileContainer(ev,
- storage->GetSession(ev),
- (FSSpec*) id->_buffer);
- }
- _fTargetDocument = (CMDocument*) _fTargetContainer->AcquireDocument(ev, kODDefaultDocument);
- if (fileLocked == kODFalse)
- file.Unlock();
-
- CATCH_ALL
-
- if (fileLocked == kODFalse)
- file.Unlock();
-
- RERAISE;
-
- ENDTRY
-
- _fHandle = ODNewHandle(0);
-
- ODByteArray* ba = CreateByteArray(&_fHandle, sizeof(ODHandle));
- parent_InitContainer(somSelf, ev, storage, ba);
- DisposeByteArray(ba);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODUpdateContainer: GetTargetFileContainer
- //------------------------------------------------------------------------------
-
- SOM_Scope ODBentoContainer* SOMLINK ODUpdateContainerGetTargetContainer(ODUpdateContainer *somSelf, Environment *ev)
- {
- ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
- ODUpdateContainerMethodDebug("ODUpdateContainer","GetTargetContainer");
-
- return _fTargetContainer;
- }
-
- //------------------------------------------------------------------------------
- // ODUpdateContainer: GetTargetDocument
- //------------------------------------------------------------------------------
-
- SOM_Scope CMDocument* SOMLINK ODUpdateContainerGetTargetDocument(ODUpdateContainer *somSelf, Environment *ev)
- {
- ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
- ODUpdateContainerMethodDebug("ODUpdateContainer","GetTargetDocument");
-
- return _fTargetDocument;
- }
-