home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osr1.exe / src / DragPriv.cpp < prev    next >
C/C++ Source or Header  |  1997-03-21  |  19KB  |  596 lines

  1. /* @(#)Z 1.14 com/src/storage/DragPriv.cpp, oddataxfer, od96os2, odos29712d 97/03/21 17:18:34 (96/10/29 09:31:05) */
  2. //====START_GENERATED_PROLOG======================================
  3. //
  4. //
  5. //   COMPONENT_NAME: oddataxfer
  6. //
  7. //   CLASSES: none
  8. //
  9. //   ORIGINS: 82,27
  10. //
  11. //
  12. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  13. //   All Rights Reserved
  14. //   Licensed Materials - Property of IBM
  15. //   US Government Users Restricted Rights - Use, duplication or
  16. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  17. //       
  18. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  19. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  21. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  22. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  23. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  24. //   OR PERFORMANCE OF THIS SOFTWARE.
  25. //
  26. //====END_GENERATED_PROLOG========================================
  27. //
  28.  
  29. /*
  30.     File:        DragPriv.cpp
  31.  
  32.     Contains:    Implementation of Private classes for ODDragAndDrop.
  33.  
  34.     Owned by:    Vincent Lo
  35.  
  36.     Copyright:    ⌐ 1994 - 1995 by Apple Computer, Inc., all rights reserved.
  37.  
  38.     Change History (most recent first):
  39.  
  40.         <27>    10/13/95    EL        1287340: Use standard ISO prefix
  41.         <26>     10/4/95    jpa        Added missing ODVolatiles [1285799]
  42.         <25>     10/4/95    VL        1287585: Check to see whether we are
  43.                                     dragging a folder before getting the file
  44.                                     info.
  45.         <24>     9/13/95    VL        1283523: Stop copying names for stationery
  46.                                     files.
  47.         <23>      9/8/95    VL        1274572: Preserved the curResFile in
  48.                                     GetIconFamilyFromFile.
  49.         <22>      9/8/95    Té        1281096 FB2:Many constants in ODTypesB
  50.                                     without kOD prefix!
  51.         <21>      9/6/95    VL        1274572: Added GetFinderInfo and
  52.                                     GetIconFamilyFromFile.
  53.         <20>     8/12/95    Té        1276812 Need to use TempObjs and TempRefs
  54.                                     for exception safety and to avoid TRY
  55.                                     blocks, 1276807 Opt./Bug: use StdTypIO
  56.                                     routines for portable streaming & smaller
  57.                                     footprint
  58.         <19>     7/26/95    VL        1270320: ClearAllPromises when deleting
  59.                                     memory container.
  60.         <18>     5/26/95    VL        1251403: Multithreading naming support.
  61.         <17>     5/25/95    jpa        Fixed usage of ODDebug. [1253321]
  62.         <16>     4/25/95    VL        1240737: Make sure that ID for file
  63.                                     container is set to the right _length.
  64.         <15>     4/15/95    VL        1240014: turned off debug statements.
  65.         <14>     4/14/95    VL        Temporarily turned on debug printf.
  66.         <13>     3/10/95    VL        1227218: Get rid of system heap.
  67.         <12>     2/27/95    VL        1198037: Removed debugstr from code.
  68.         <11>     2/10/95    VL        1205627: Used kODBentoUpdateContainer.
  69.         <10>     1/26/95    VL        #???: Use updated Storage Unit Ref API.
  70.          <9>     1/19/95    CC        1212419 Pass kODBentoMemoryContainer to
  71.                                     CreateMemoryContainer & GetMemoryContainer.
  72.          <8>    12/20/94    VL        1195012: Make Storage calls be
  73.                                     marshallable.
  74.          <7>    12/13/94    VL        1203627,1200603,1203451,1198037,1194537,119
  75.                                     4755,1186815: Bug fixes.
  76.          <6>     9/23/94    VL        1184272: ContainerID is now a sequence of
  77.                                     octets.
  78.          <5>     8/26/94    VL        1183174: Use updated cloning APIs
  79.                                     (specifically GetStorageUnitRef takes ID
  80.                                     now).
  81.          <4>     8/15/94    Té        #1180922 Removed most obsolete types from
  82.                                     StdTypes.idl
  83.          <3>      8/3/94    VL        1153123: Storage to ODStor.
  84.          <2>     7/26/94    VL        Got rid of dependency on Bento.
  85.          <1>     7/21/94    VL        first checked in
  86.  
  87.     To Do:
  88.     In Progress:
  89. */
  90.  
  91. #ifndef _DRAGPRIV_
  92. #include <DragPriv.h>
  93. #endif
  94.  
  95. #ifndef SOM_ODStorageSystem_xh
  96. #include <ODStor.xh>
  97. #endif
  98.  
  99. #ifndef SOM_ODContainer_xh
  100. #include <ODCtr.xh>
  101. #endif
  102.  
  103. #ifndef SOM_ODDocument_xh
  104. #include <Document.xh>
  105. #endif
  106.  
  107. #ifdef _PLATFORM_MACINTOSH_
  108. #ifndef SOM_ODDraft_xh
  109. #include <ODDraft.xh>
  110. #endif
  111. #endif // _PLATFORM_MACINTOSH_
  112.  
  113. #ifndef SOM_ODStorageUnit_xh
  114. #include <StorageU.xh>
  115. #endif
  116.  
  117. #ifndef _ODMEMORY_
  118. #include "ODMemory.h"
  119. #endif
  120.  
  121. #ifndef _STDTYPIO_
  122. #include "StdTypIO.h"
  123. #endif
  124.  
  125. #ifndef _TEMPOBJ_
  126. #include "TempObj.h"
  127. #endif
  128.  
  129. #ifndef SOM_Module_OpenDoc_StdProps_defined
  130. #include <StdProps.xh>
  131. #endif
  132.  
  133. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  134. #include <StdTypes.xh>
  135. #endif
  136.  
  137. #if (defined(_PLATFORM_WIN32_) || defined(_PLATFORM_OS2_) || defined(_PLATFORM_AIX_))
  138. #ifndef _ODUTILS_
  139. #include <ODUtils.h>                //  for ODReleaseObject
  140. #endif
  141. #ifdef DAD_DEBUG
  142. #include "qprintf.h"
  143. #endif // DAD_DEBUG
  144. #endif // _PLATFORM_WIN32_ || _PLATFORM_OS2_ || _PLATFORM_AIX__
  145.  
  146. #ifdef _PLATFORM_OS2_
  147. #include <stdio.h>                    // for sprintf
  148. #endif // _PLATFORM_OS2_
  149.  
  150. #ifndef _STORUTIL_
  151. #include <StorUtil.h>
  152. #endif
  153.  
  154. #ifndef _BARRAY_
  155. #include <BArray.h>
  156. #endif
  157.  
  158. #ifndef _ISOSTR_
  159. #include <ISOStr.h>
  160. #endif
  161.  
  162. #ifdef _PLATFORM_MACINTOSH_
  163. #ifndef _INFOUTIL_
  164. #include <InfoUtil.h>
  165. #endif
  166.  
  167. #ifndef _ICONS_
  168. #include <Icons.h>
  169. #endif
  170.  
  171. #ifndef __FINDER__
  172. #include <Finder.h>
  173. #endif
  174.  
  175. #if ODDebug
  176. #ifndef __STRINGS__
  177. #include <Strings.h>
  178. #endif
  179. #endif // ODDebug
  180. #endif // _PLATFORM_MACINTOSH_
  181.  
  182. #ifndef _USERSRCM_
  183. #include <UseRsrcM.h>
  184. #endif
  185.  
  186. #if ODDebug
  187. // #define ODDebug_DragPriv    1
  188. #endif
  189.  
  190. const ODContainerType kODBentoUpdateContainer = "+//ISO 9070/ANSI::113722::US::CI LABS::OpenDoc:Bento Container Suite:ContainerType:Update";
  191.  
  192. //==============================================================================
  193. // Function Prototype
  194. //==============================================================================
  195.  
  196. ODContainerType    GetContainerSuiteType(FSSpec* fsSpec);
  197.  
  198. //==============================================================================
  199. // ODDragItem
  200. //==============================================================================
  201. //------------------------------------------------------------------------------
  202. // ODDragItem::ODDragItem
  203. //------------------------------------------------------------------------------
  204. ODDragItem::ODDragItem(ODStorageSystem *storage, ODBoolean IsForeignDataSU)
  205. {
  206.     fStorageSystem = storage;
  207.     fContainer = kODNULL;
  208.     fDocument = kODNULL;
  209.     fDraft = kODNULL;
  210.     fSU = kODNULL;
  211. }
  212.  
  213. void ODDragItem::Open(Environment* ev)
  214. {
  215.     WARNMSG_DEBUG(WARN_INDEX(-1),"ODDragItem::Open should not be called.");
  216. }
  217.  
  218.  
  219. void ODDragItem::Close(Environment* ev)
  220. {
  221.     WARNMSG_DEBUG(WARN_INDEX(-1),"ODDragItem::Close should not be called.");
  222. }
  223.  
  224. //==============================================================================
  225. // ODMemDragItem
  226. //==============================================================================
  227. //------------------------------------------------------------------------------
  228. // ODMemDragItem::~ODMemDragItem
  229. //------------------------------------------------------------------------------
  230. ODMemDragItem::~ODMemDragItem()
  231. {
  232.     Environment* ev = somGetGlobalEnvironment();
  233.  
  234. #ifdef DAD_DEBUG
  235.     qprintf("Destructing ODMemDragItem %08p, fContainerHandle = %08p:\n", this, fContainerHandle);
  236.     qprintf("\tfContainer = %08p, ref count = %d\n",
  237.             fContainer, fContainer->GetRefCount(ev));
  238.     qprintf("\tfDocument = %08p, ref count = %d\n",
  239.             fDocument, fDocument->GetRefCount(ev));
  240.     qprintf("\tfDraft = %08p, ref count = %d\n",
  241.             fDraft, fDraft->GetRefCount(ev));
  242.     qprintf("\tfSU = %08p, ref count = %d\n",
  243.             fSU, fSU->GetRefCount(ev));
  244. #endif  // DAD_DEBUG
  245.     if (fSU != kODNULL)
  246.     {
  247.         fSU->ClearAllPromises(ev);
  248.         fSU->Release(ev);
  249.     }
  250.     if (fDraft != kODNULL)
  251.         fDraft->Release(ev);
  252.     if (fDocument != kODNULL)
  253.         fDocument->Release(ev);
  254.     if (fContainer != kODNULL)
  255.         fContainer->Release(ev);
  256.     ODDisposeHandle(fContainerHandle);
  257. }
  258.  
  259. //------------------------------------------------------------------------------
  260. // ODMemDragItem::Initialize
  261. //------------------------------------------------------------------------------
  262. void ODMemDragItem::Initialize(Environment* ev)
  263. {
  264.     ODDragItem::Initialize(ev);
  265.     
  266.     fContainerHandle = ODNewHandle(0);
  267.     ASSERTMSG_DEBUG(MemError() == noErr, MemError(), "Error allocating D&D container handle");
  268.  
  269.     fContainer = CreateMemoryContainer(ev, fStorageSystem->GetSession(ev), fContainerHandle, kODBentoMemoryContainer);
  270.     fDocument = fContainer->AcquireDocument(ev, kODDefaultDocument);        
  271.     fDraft = fDocument->AcquireBaseDraft(ev, kODDPExclusiveWrite);
  272.     fSU = fDraft->CreateStorageUnit(ev);
  273.     TempODStorageUnit draftProperties = fDraft->AcquireDraftProperties(ev);
  274.     ODSetStrongSURefProp(ev, draftProperties, kODPropRootPartSU, kODStrongStorageUnitRef, fSU->GetID(ev));
  275. #ifdef DAD_DEBUG
  276.     qprintf("Initializing ODMemDragItem %08p, fContainerHandle = %08p:\n", this, fContainerHandle);
  277.     qprintf("\tfContainer = %08p, ref count = %d\n",
  278.             fContainer, fContainer->GetRefCount(ev));
  279.     qprintf("\tfDocument = %08p, ref count = %d\n",
  280.             fDocument, fDocument->GetRefCount(ev));
  281.     qprintf("\tfDraft = %08p, ref count = %d\n",
  282.             fDraft, fDraft->GetRefCount(ev));
  283.     qprintf("\tfSU = %08p, ref count = %d\n",
  284.             fSU, fSU->GetRefCount(ev));
  285. #endif  // DAD_DEBUG
  286. }
  287.  
  288. //------------------------------------------------------------------------------
  289. // ODMemDragItem::Open
  290. //------------------------------------------------------------------------------
  291. void ODMemDragItem::Open(Environment* ev)
  292. {
  293.     fContainer = GetMemoryContainer(ev, fStorageSystem->GetSession(ev), fContainerHandle, kODBentoMemoryContainer);
  294.     fDocument = fContainer->AcquireDocument(ev, kODDefaultDocument);
  295.     fDraft = fDocument->AcquireBaseDraft(ev, kODDPExclusiveWrite);
  296.     TempODStorageUnit    draftProperties = fDraft->AcquireDraftProperties(ev);
  297.     fSU = fDraft->AcquireStorageUnit(ev, ODGetStrongSURefProp(ev, draftProperties, kODPropRootPartSU, kODStrongStorageUnitRef));
  298.  
  299. #ifdef DAD_DEBUG
  300.     qprintf("Opening ODMemDragItem %08p, fSU %08p\n", this, fSU);
  301. #endif  // DAD_DEBUG
  302. }
  303.  
  304. //------------------------------------------------------------------------------
  305. // ODMemDragItem::Close
  306. //------------------------------------------------------------------------------
  307. void ODMemDragItem::Close(Environment* ev)
  308. {
  309. #ifdef DAD_DEBUG
  310.     qprintf("Closing ODMemDragItem %08p, fSU %08p\n", this, fSU);
  311. #endif  // DAD_DEBUG
  312.  
  313.     if (fSU != kODNULL) {
  314.         fSU->Release(ev);
  315.     }
  316.     if (fDraft != kODNULL) {
  317.         fDraft->Externalize(ev);
  318.         fDraft->Release(ev);
  319.     }
  320.     if (fDocument != kODNULL)
  321.         fDocument->Release(ev);
  322.     if (fContainer != kODNULL)
  323.         fContainer->Release(ev);
  324. }
  325.  
  326. #ifdef _PLATFORM_AIX_
  327. //------------------------------------------------------------------------------
  328. // ODMemDragItem::Restore
  329. //------------------------------------------------------------------------------
  330. void ODMemDragItem::Restore(Environment* ev, void *containerData, int containerSize)
  331. {
  332.     // initialize the drag item, then close it so we can set its data
  333.     Initialize(ev);
  334.     Close(ev);
  335.  
  336.     // copy data into memory container
  337.     fContainerHandle = ODNewHandle((ODULong)containerSize);
  338.     ASSERTMSG_DEBUG(MemError() == noErr, MemError(), "Error allocating D&D container handle");
  339.     memcpy(*((void **)fContainerHandle), containerData,
  340.         (size_t)containerSize);
  341.  
  342.     // now open the new drag item (this causes the drag item to 'commit'
  343.     // its new data to a real live container object)
  344.     Open(ev);
  345. }
  346. #endif
  347.  
  348. //==============================================================================
  349. // ODFileDragItem
  350. //==============================================================================
  351. //------------------------------------------------------------------------------
  352. // ODFileDragItem::~ODFileDragItem
  353. //------------------------------------------------------------------------------
  354. ODFileDragItem::~ODFileDragItem()
  355. {
  356. #if ODDebug_DragPriv
  357.     somPrintf("~ODFileDragItem: %x %x %x %x\n", fSU, fDraft, fDocument, fContainer);
  358. #endif
  359.  
  360.     Environment* ev = somGetGlobalEnvironment();
  361.     
  362.     if (fSU != kODNULL)
  363.         fSU->Release(ev);
  364.     if (fDraft != kODNULL)
  365.         fDraft->Release(ev);
  366.     if (fDocument != kODNULL)
  367.         fDocument->Release(ev);
  368.     if (fContainer != kODNULL)
  369.         fContainer->Release(ev);
  370. }
  371.  
  372. //------------------------------------------------------------------------------
  373. // ODFileDragItem::Initialize
  374. //------------------------------------------------------------------------------
  375. void ODFileDragItem::Initialize(Environment* ev, ODContainerID* containerID)
  376. {
  377.     ODDragItem::Initialize(ev);
  378.     
  379.     ODStorageUnitID    suid;
  380.     ODContainerType containerType = kODNULL;    ODVolatile(containerType);
  381.         
  382.     TRY
  383.         containerType = GetContainerSuiteType((FSSpec*) containerID->_buffer);
  384.         containerID->_length = strlen((char *)&(((FSSpec*) containerID->_buffer)->name[0])) + 1;
  385.         fContainer = fStorageSystem->CreateContainer(ev, containerType, containerID);
  386.         fDocument = fContainer->AcquireDocument(ev, kODDefaultDocument);        
  387.         fDraft = fDocument->AcquireBaseDraft(ev, kODDPExclusiveWrite);
  388.         TempODStorageUnit    draftProperties = fDraft->AcquireDraftProperties(ev);
  389.         suid = ODGetStrongSURefProp(ev, draftProperties, kODPropRootPartSU, kODStrongStorageUnitRef);
  390.         fSU = fDraft->AcquireStorageUnit(ev, suid);
  391.         ODDisposePtr(containerType);
  392. #if ODDebug_DragPriv
  393.     somPrintf("ODFileDragItem::Initialize %x %x %x %x\n", fSU, fDraft, fDocument, fContainer);
  394. #endif
  395.  
  396.     CATCH_ALL
  397. #ifdef ODDebug_DragPriv
  398.         ODError err = ErrorCode();
  399.         WARNMSG_DEBUG(WARN_INDEX(-1),"Error in ODFileDragItem::Initialize");
  400.         char    errString[100];
  401.         numtostring(err, errString);
  402.         WARNMSG_DEBUG(WARN_INDEX(-1),errString);
  403. #endif
  404.         ODReleaseObject(ev,fSU);
  405.         ODReleaseObject(ev,fDraft);
  406.         ODReleaseObject(ev,fDocument);
  407.         ODReleaseObject(ev,fContainer);
  408.         ODDisposePtr(containerType);
  409.         RERAISE;
  410.     ENDTRY
  411. }
  412.  
  413. //==============================================================================
  414. // ODDragLink
  415. //==============================================================================
  416. //------------------------------------------------------------------------------
  417. // ODDragLink::ODDragLink
  418. //------------------------------------------------------------------------------
  419. ODDragLink::ODDragLink(ODDragItem *theItem, ODBoolean cleanup)
  420. {
  421.     fItem = theItem;
  422.     fCleanup = cleanup;
  423. }
  424.  
  425. //------------------------------------------------------------------------------
  426. // ODDragLink::~ODDragLink
  427. //------------------------------------------------------------------------------
  428. ODDragLink::~ODDragLink()
  429. {
  430.     if (fCleanup)
  431.         delete fItem;
  432. }
  433.  
  434. #ifdef _PLATFORM_OS2_
  435. //==============================================================================
  436. // ODDragRMF
  437. //==============================================================================
  438. //------------------------------------------------------------------------------
  439. // ODDragRMF::ODDragRMF
  440. //------------------------------------------------------------------------------
  441. ODDragRMF::ODDragRMF(PSZ pszRMF)
  442. {
  443.     fRMF = strdup(pszRMF);
  444. }
  445.  
  446. //------------------------------------------------------------------------------
  447. // ODDragRMF::~ODDragRMF
  448. //------------------------------------------------------------------------------
  449. ODDragRMF::~ODDragRMF()
  450. {
  451.     free(fRMF);
  452. }
  453.  
  454. struct StdFmtKind
  455. {
  456.     PSZ kindName;
  457.     PSZ pszFormat;
  458. };
  459.  
  460. static const StdFmtKind StdFmtKinds[] =
  461. {
  462.     kODKindOS2Bitmap,        "DRF_BITMAP",
  463.     kODKindOS2DspBitmap,     "DRF_DSPBITMAP",
  464.     kODKindOS2Metafile,      "DRF_METAFILE",
  465.     kODKindOS2Text,          "DRF_TEXT",
  466.     kODKindOS2DIB,           "DRF_DIB",
  467.     kODKindOS2DIF,           "DRF_DIF",
  468.     kODKindOS2OEMText,       "DRF_OEMTEXT",
  469.     kODKindOS2OwnerDisplay,  "DRF_OWNERDISPLAY",
  470.     kODKindOS2PtrPict,       "DRF_PTRPICT",
  471.     kODKindOS2RTF,           "DRF_RTF",
  472.     kODKindOS2SYLK,          "DRF_SYLK",
  473.     kODKindOS2TIFF,          "DRF_TIFF",
  474.     kODKindOS2Unknown,       "DRF_UNKNOWN"
  475. };
  476.  
  477. static const StdFmtKind StdTypeKinds[] =
  478. {
  479.     kODKindOS2Bitmap,        "DRT_BITMAP",
  480.     kODKindOS2Metafile,      "DRT_METAFILE",
  481.     kODKindOS2Text,          "DRT_TEXT",
  482.     kODKindOS2Unknown,       "DRF_UNKNOWN"
  483. };
  484.  
  485. #define NumStdFormats  (sizeof(StdFmtKinds)/sizeof(StdFmtKind))
  486.  
  487. PSZ GetKindForFormat(PSZ fmt)
  488. {
  489.     for(int i=0; i<NumStdFormats; i++)
  490.         if(!strcmp(fmt,StdFmtKinds[i].pszFormat))
  491.             return StdFmtKinds[i].kindName;
  492.     return kODNULL;
  493. }
  494.  
  495. ODBoolean GetRMFForKind(PSZ kind, PSZ pszRMF)
  496. {
  497.     for(int i=0; i<NumStdFormats; i++)
  498.         if(!strcmp(kind,StdFmtKinds[i].kindName))
  499.         {
  500.             sprintf(pszRMF,"<DRM_OS2FILE,%s>",StdFmtKinds[i].pszFormat);
  501.             return kODTrue;
  502.         }
  503.     return kODFalse;
  504. }
  505. #endif // _PLATFORM_OS2_
  506.  
  507. //------------------------------------------------------------------------------
  508. // GetContainerSuiteType
  509. //------------------------------------------------------------------------------
  510. ODContainerType    GetContainerSuiteType(FSSpec* fsSpec)
  511. {
  512. #if USE_GETCONTAINER_SUITE_TYPE
  513.     PlatformFile    file;
  514.     file.Specify(fsSpec);
  515.     
  516.     ODContainerType containerType = file.AcquireContainerType();
  517.     if (ODISOStrEqual(containerType, kODBentoFileContainer) || 
  518.         ODISOStrEqual(containerType, ""))
  519.     {
  520.         containerType = kODBentoUpdateContainer;
  521.     }
  522. #else
  523.     ODULong len = strlen(kODBentoUpdateContainer);
  524.     ODContainerType containerType = (ODContainerType) ODNewPtr(len + 1);
  525.     strcpy(containerType, kODBentoUpdateContainer);
  526.     return containerType;
  527. #endif // USE_GETCONTAINER_SUITE_TYPE
  528. }
  529.  
  530. #ifdef _PLATFORM_MACINTOSH
  531. //------------------------------------------------------------------------------
  532. // GetFinderInfo
  533. //------------------------------------------------------------------------------
  534. void GetFinderInfo(Environment* ev, ODStorageUnit* su, PlatformFile* file)
  535. {
  536.     if (!file->IsDirectory())
  537.     {
  538.         ODTime creationDate = file->GetFileCreationDate();
  539.         ODSetCreationDate(ev, su, creationDate);
  540.         ODTime modDate = file->GetFileModDate();
  541.         ODSetModificationDate(ev, su, modDate);
  542.     
  543.         if (!file->IsStationery())
  544.         {    
  545.             ODName* name = file->GetName();
  546.             ODSetPONameUsingSU(ev, su, name);
  547.             DisposeIText(name);
  548.         }
  549.     
  550.         // Stationery bit is purposedly left out.
  551.     }
  552. }
  553.  
  554. //------------------------------------------------------------------------------
  555. // GetIconFamilyFromFile
  556. //------------------------------------------------------------------------------
  557. void GetIconFamilyFromFile(Environment* ev, ODStorageUnit* su, PlatformFile* file)
  558. {
  559.     if (!file->IsDirectory())
  560.     {
  561.         Handle iconFamily;
  562.         
  563.         short refNum = 0;
  564.         ODBoolean hasCustomIcon;
  565.         OSErr err = noErr;
  566.         ODVolatile(err);
  567.         TRY
  568.             hasCustomIcon = file->HasCustomIcon();
  569.             if (hasCustomIcon)
  570.             {
  571.                 file->SetPermission(fsRdPerm);
  572.                 refNum = CurResFile();
  573.                 file->OpenResFile();
  574.             }
  575.         CATCH_ALL
  576.             UseResFile(refNum);
  577.         ENDTRY
  578.         
  579.         if (hasCustomIcon && (err == noErr))
  580.         {        
  581.             err = GetIconSuite(&iconFamily, kCustomIconResource, svAllAvailableData);
  582.             if (err == noErr)
  583.             {
  584.                 ODSetIconFamilyProp(ev, su, kODPropCustomIcon, kODIconFamily, iconFamily, kODFalse);
  585.                 DisposeIconSuite(iconFamily, true);
  586.             }
  587. #ifdef ODDEBUG
  588.             else
  589.                 WARN("Problem getting icon family: %d ", err);
  590. #endif
  591.             file->CloseResFile();
  592.         }
  593.     }
  594. }
  595. #endif // _PLATFORM_MACINTOSH_
  596.