home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Snippets / DirectoryPopup 1.0 / □□□DPSample Source / Utilities.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-02  |  1.1 KB  |  65 lines  |  [TEXT/CWIE]

  1. /*
  2.  *    Project:        SimpleApp
  3.  *
  4.  *    Filename:         Utilities.c
  5.  *
  6.  *    Author:         Marco Piovanelli
  7.  *
  8.  *    Revision History:
  9.  *
  10.  *            1996.05.24                MP        created this file
  11.  *
  12.  */
  13.  
  14. #include "Utilities.h"
  15.  
  16. void Assert ( Boolean inAssertion )
  17. {
  18.     if ( ! inAssertion )
  19.     {
  20.         DebugStr ( "\pAssertion Failed" ) ;
  21.     }
  22. }
  23.  
  24. void BlockClear ( void * ioBlockPtr, Size inBlockSize )
  25. {
  26.     register char * p = ( char * ) ioBlockPtr ;
  27.  
  28.     while ( -- inBlockSize >= 0 )
  29.     {
  30.         * p ++ = 0 ;
  31.     }
  32. }
  33.  
  34. void InitDesc ( AEDesc * ioDesc )
  35. {
  36.     ioDesc -> descriptorType = typeNull ;
  37.     ioDesc -> dataHandle = nil ;
  38. }
  39.  
  40. void ForgetDesc ( AEDesc * ioDesc )
  41. {
  42.     if ( ( ioDesc -> descriptorType != typeNull ) || ( ioDesc -> dataHandle != nil ) )
  43.     {
  44.         AEDisposeDesc ( ioDesc ) ;
  45.     }
  46. }
  47.  
  48. OSErr FindParentSpec ( FSSpec * ioFileSpec )
  49. {
  50.     CInfoPBRec pb ;
  51.     OSErr err ;
  52.     
  53.     BlockClear ( & pb, sizeof ( pb ) ) ;
  54.     pb . dirInfo . ioVRefNum = ioFileSpec -> vRefNum ;
  55.     pb . dirInfo . ioDrDirID = ioFileSpec -> parID ;
  56.     pb . dirInfo . ioFDirIndex = -1 ;
  57.     pb . dirInfo . ioNamePtr = ioFileSpec -> name ;
  58.  
  59.     err = PBGetCatInfoSync ( & pb ) ;
  60.  
  61.     ioFileSpec -> parID = pb . dirInfo . ioDrParID ;
  62.     
  63.     return err ;
  64. }
  65.