home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 May / macformat-050.iso / Shareware Plus / Developers / Find_icon folder / Sources / Get_custom_folder_icon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-25  |  1.9 KB  |  62 lines  |  [TEXT/CWIE]

  1. /*    ---------------------------------------------------------------------------------------------
  2.     Find_icon, code for constructing icon suites for files and folders
  3.     
  4.     by James W. Walker
  5.     preferred e-mail: <mailto:jwwalker@kagi.com>
  6.     alternate e-mail: <mailto:jwwalker@aol.com>, <jim@nisus-soft.com>
  7.     web: <http://users.aol.com/jwwalker/>
  8.     
  9.     File: Get_custom_folder_icon.c
  10.     
  11.     Copyright ©1997 by James W. Walker
  12.     
  13.     You may incorporate this sample code into your applications without
  14.     restriction, though the sample code has been provided "AS IS" and the
  15.     responsibility for its operation is 100% yours.
  16.     If you're going to re-distribute the source, please make it clear
  17.     that the code was descended from James W. Walker's code,
  18.     but that you've made changes.
  19.     ---------------------------------------------------------------------------------------------
  20. */
  21.  
  22. #include <Icons.h>
  23. #include "Get_custom_folder_icon.h"
  24. #include "Get_custom_file_icon.h"
  25. #include "Get_icon_file_name.h"
  26.  
  27. static    Str31    sIconFileName = "\p";
  28.  
  29. /*    ------------------------------------------------------------------
  30.     Get_custom_folder_icon        Given a directory that is known to have
  31.                                 a custom icon, create an icon suite
  32.                                 for it.
  33.     
  34.     The icons are stored in an invisible file whose name, on a U.S.
  35.     system, is "\pIcon\r".  Unfortunately the name can vary in other
  36.     countries, and is stored in the Finder.
  37.     ------------------------------------------------------------------
  38. */
  39. OSErr    Get_custom_folder_icon(
  40. /* --> */    short                vRefNum,
  41. /* --> */    long                dirID,
  42. /* --> */    MetaSelectorValue    icon_selector,
  43. /* <-- */    Handle                *the_suite
  44. )
  45. {
  46.     FSSpec    icon_file;
  47.     OSErr    err;
  48.     
  49.     if (sIconFileName[0] == 0)
  50.     {
  51.         Get_icon_file_name( sIconFileName );
  52.     }
  53.     
  54.     err = FSMakeFSSpec( vRefNum, dirID, sIconFileName, &icon_file );
  55.     
  56.     if (err == noErr)
  57.     {
  58.         err = Get_custom_file_icon( &icon_file, icon_selector, the_suite );
  59.     }
  60.     return err;
  61. }
  62.